diff --git a/CHANGES.md b/CHANGES.md index 60487c62d..653a63557 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,256 @@ twilio-python Changelog Here you can see the full list of changes between each twilio-python release. +[2026-09-09] Version 9.11.1 +--------------------------- +**Library - Fix** +- [PR #954](https://github.com/twilio/twilio-python/pull/954): Fix tag validation regex in deploy.yml. Thanks to [@kridai](https://github.com/kridai)! + +**Audiences** +- ## 2026-09-01 +- Backticked brace- and angle-bracket-bearing tokens in descriptions for MDX safety. +- Updated a prose reference to the renamed `FetchCohortSnapshot` operation. +- ## 2026-08-26 +- **Removed 5 path(s)**: +- `/preview/Audiences` (AdminListAudiences) +- `/preview/Audiences/{audienceId}` (AdminGetAudience) +- `/preview/Snapshots` (AdminListSnapshots) +- `/preview/Snapshots/{snapshotId}` (AdminGetSnapshot) +- `/preview/Operations/{operationId}` (AdminGetOperation) +- ## 2026-08-25 +- Minor updates (formatting, metadata) +- ## 2026-08-24 +- **Added 1 new path(s)**: +- `/preview/Snapshots/{cohortSnapshotId}/Operations` (AdminListSnapshotOperations) +- **Removed 1 path(s)**: +- `/preview/Snapshots/{snapshotId}/Operations` (ListAdminSnapshotOperations) +- ## 2026-08-20 +- Renamed all 13 operations so the operationId keyword leads (`AdminGetCohort` -> `FetchAdminCohort`) to meet standard. +- Set `info` `libraryVisibility` to `hidden` to exclude this admin spec from generation. +- Added the standard `pageSize`/`pageToken` query parameters to `ListAdminSnapshotOperations`, the only list operation missing them. +- ## 2026-08-19 +- **Added 5 new path(s)**: +- `/preview/Cohorts` (AdminListCohorts) +- `/preview/Cohorts/{cohortId}` (AdminGetCohort) +- `/preview/CohortSnapshots` (AdminListCohortSnapshots) +- `/preview/CohortSnapshots/{cohortSnapshotId}` (AdminGetCohortSnapshot) +- `/preview/CohortOperations/{cohortOperationId}` (AdminGetCohortOperation) +- ## 2026-09-01 +- Renamed 3 `Get*` operations to `Fetch*` to match the operationId standard: `FetchCohort`, `FetchCohortSnapshot`, `FetchCohortOperation`. The transpiler skips operations whose operationId does not start with a standard keyword, which had been dropping all three from generated output. +- Set `libraryVisibility` to `private` (was `hidden`) so the spec is eligible for the private docs pipeline. +- Backticked brace- and angle-bracket-bearing tokens in descriptions for MDX safety. +- ## 2026-08-28 +- **Removed 6 path(s)**: +- `/preview/Audiences` (ListAudiences, CreateAudience) +- `/preview/Audiences/{audienceId}` (FetchAudience, UpdateAudience, DeleteAudience) +- `/preview/Snapshots` (ListSnapshots, CreateSnapshot) +- `/preview/Snapshots/{snapshotId}` (FetchSnapshot, DeleteSnapshot) +- `/preview/Snapshots/{snapshotId}/Profiles` (ListSnapshotProfiles) +- `/preview/Operations/{operationId}` (FetchOperation) +- ## 2026-08-20 +- Renamed 6 `Get*` operations to `Fetch*` to match the operationId standard. +- Hid the deprecated Audiences/Snapshots paths and `/preview/Operations/{operationId}`. +- Backticked 11 brace-bearing tokens in descriptions for MDX safety. + +**Conversations** +- Add PATCH support for partial updates to Configuration +- Add `VIDEO` to the Conversations v2 Communication channel enum. + +**Data-ingress** +- # API Changes +- ## 2026-09-01 +- Minor updates (formatting, metadata) +- ## 2026-08-12 +- Minor updates (formatting, metadata) +- ## 2026-08-12 +- Initial release with 13 paths and 13 operations + +**Destinations** +- ## 2026-09-08 +- Added `prod-ie1` to `supportedRealms` and `iamOperationEnabledRealms` for all endpoints +- ## 2026-09-01 +- Removed the unused `admin-api` placeholder from `supportedRealms` on the public endpoints; +- One Admin routes now live in `admin_openapi.yaml`. +- **Added 6 new path(s)** (admin_openapi.yaml): +- `/v1/ControlPlane/Destinations` (AdminListDestinations) +- `/v1/ControlPlane/Destinations/{destinationId}` (AdminGetDestination) +- `/v1/ControlPlane/Subscriptions` (AdminListSubscriptions) +- `/v1/ControlPlane/Subscriptions/{subscriptionId}` (AdminGetSubscription) +- `/v1/ControlPlane/Subscriptions/{subscriptionId}/EventTypes` (AdminListSubscribedEvents) +- `/v1/ControlPlane/Subscriptions/{subscriptionId}/EventTypes/{eventType}` (AdminGetSubscribedEvent) +- ## 2026-08-26 +- Minor updates (formatting, metadata) +- ## 2026-08-26 +- Minor updates (formatting, metadata) +- ## 2026-08-25 +- **Content updates**: +- Updated description for `CreateDestination` +- ## 2026-08-12 +- Minor updates (formatting, metadata) +- ## 2026-08-12 +- **Content updates**: +- Added properties to `DestinationType`: releaseStatus +- Removed properties from `DestinationType`: maturity + +**Email** +- # API Changes +- ## 2026-09-02 +- **Added 1 new path(s)**: +- `/v1/Sends/Cohorts` (sendCohort) +- ## 2026-08-28 +- **Content updates**: +- Updated summary for `sendTransactional` +- Added parameter(s) to `sendTransactional`: X-Twilio-Version +- Updated schema description for `SuppressionsGroup` +- Added properties to `SuppressionsGroup`: type +- Removed properties from `SuppressionsGroup`: mode +- Updated schema description for `SuppressionsGlobal` +- Added properties to `SuppressionsGlobal`: type +- Removed properties from `SuppressionsGlobal`: mode +- Updated schema description for `Suppressions` +- Updated schema description for `LongRunningOperationResponse` +- ## 2026-08-27 +- **Content updates**: +- Updated description for `SendEmail` +- Added parameter(s) to `SendEmail`: Content-Encoding, Idempotency-Key +- Updated schema description for `Envelope` +- Updated schema description for `SuppressionsGroup` +- Updated schema description for `SuppressionsGlobal` + +**Iam** +- Removed redirect_urls from the GET /v1/Account/AuthorizedApps/{consentSid} response +- Added company_name, homepage_url, tos_url, and redirect_urls to the GET /v1/Account/AuthorizedApps/{consentSid} response +- Added GET /v1/Account/AuthorizedApps/{consentSid} - fetch authorized app details, including allowed permissions, by consent identifier SID +- added container-scoped entitlements endpoint (GET /v2/Container/{containerId}/Entitlements) + +**Instrumentation** +- # API Changes +- ## 2026-09-04 +- **Content updates**: +- Added `IdempotencyKeyHeader` to Create/Patch/Delete `AutoInstrumentationRule`; corrected the shared header's description +- Added `operationId`/`createdAt` to `LongRunningOperationResponse`; corrected example `status` from `RUNNING` to `PENDING` +- Renamed `Signal.timestamp` → `occurredAt`, `HourlyStats.hourTimestamp` → `hourAt`; uppercased `Signal.type` and `ListSignals`' `signalType` enums to SCREAMING_SNAKE_CASE +- Renamed `UserBehaviors` request/response fields to camelCase; added the `summaryDelivery` webhook callback +- Reshaped `PaginationMeta` (added required `key`, corrected `pageSize` bounds) and all 6 list operations (`ListEventSources`, `ListEventSourceDatasets`, `ListEventSchemas`, `ListAutoInstrumentationRules`, `ListSignals`, `ListSignalStats`) to the `meta` envelope; added `ListSignalStats`' `500` response +- Narrowed the domain's default `supportedRealms` to `dev-us1` only; `POST /v1/UserBehaviors` (`AnalyzeUserBehaviors`) keeps its own `dev-us1`/`stage-us1` override (prod withheld pending stage validation) — every other operation is now dev-only +- ## 2026-08-31 +- **Content updates**: +- Fixed stale `tdi_` TTID prefix throughout (path params, examples, transaction URLs) to `events_`; unified dataset/schema ID formats (`tdi_dat_`/`tdi_dataset_` → `events_dataset_`, `tdi_schema_` → `events_evsch_`); fixed rule-version examples to match the real `version: integer` field +- Fixed `operationId` to use the domain-agnostic `proc_job_` TTID prefix; corrected the `OperationId` parameter's length constraint (`max=34` → `max=35`) and added a `pattern` +- Fixed two length constraints hardcoded for the old `tdi_` prefix length: `IngestEventBatch`'s `sourceId` path parameter (`maxLength` 37 → 40); removed the stale, redundant `Twilio-Write-Key` header parameter +- Added the missing `AutoInstrumentationRuleId` regex `pattern` +- Fixed `info.title` ("Twilio Data Ingress - Instrumentation API" → "Events Domain - Instrumentation API") +- **Added 1 new API path**: +- `/v1/UserBehaviors` (AnalyzeUserBehaviors) +- ## 2026-07-28 +- **Initial release** — 21 paths, 37 operations across three API surfaces: +- **Control Plane** (`/v1/ControlPlane/…`): +- `/v1/ControlPlane/EventSources` (CreateEventSource, ListEventSources) +- `/v1/ControlPlane/EventSources/{sourceId}` (FetchEventSource, PatchEventSource, DeleteEventSource) +- `/v1/ControlPlane/EventSources/{sourceId}/WriteKeys` (CreateWriteKey, ListWriteKeys) +- `/v1/ControlPlane/EventSources/{sourceId}/WriteKeys/{writeKey}` (DeleteWriteKey) +- `/v1/ControlPlane/EventSources/{sourceId}/Datasets` (CreateEventSourceDataset, ListEventSourceDatasets) +- `/v1/ControlPlane/EventSources/{sourceId}/Datasets/{datasetId}` (FetchEventSourceDataset, PatchEventSourceDataset, DeleteEventSourceDataset) +- `/v1/ControlPlane/EventSources/{sourceId}/EventSchemas` (CreateEventSchema, ListEventSchemas) +- `/v1/ControlPlane/EventSources/{sourceId}/EventSchemas/{schemaId}` (FetchEventSchema, PatchEventSchema, DeleteEventSchema) +- `/v1/ControlPlane/EventSources/{sourceId}/AutoInstrumentationRules` (CreateAutoInstrumentationRule, ListAutoInstrumentationRules) +- `/v1/ControlPlane/EventSources/{sourceId}/AutoInstrumentationRules/{autoInstrumentationRuleId}` (FetchAutoInstrumentationRule, PatchAutoInstrumentationRule, DeleteAutoInstrumentationRule) +- `/v1/ControlPlane/EventSources/{sourceId}/AutoInstrumentationRules/{autoInstrumentationRuleId}/Versions` (ListAutoInstrumentationRuleVersions) +- `/v1/ControlPlane/EventSources/{sourceId}/AutoInstrumentationRules/{autoInstrumentationRuleId}/Versions/{version}` (FetchAutoInstrumentationRuleVersion) +- `/v1/ControlPlane/Datasets` (ListDatasets) +- `/v1/ControlPlane/Datasets/{datasetId}` (FetchDataset) +- `/v1/ControlPlane/Operations/{operationId}` (FetchControlPlaneOperationStatus) +- `/v1/ControlPlane/Datasets` (ListDatasets) +- `/v1/ControlPlane/Datasets/{datasetId}` (FetchDataset) +- **Event Ingestion** (`/v1/EventSources/…`): +- `/v1/EventSources/{sourceId}/Batch` (IngestEventBatch) +- `/v1/EventSources/{sourceId}/AutoInstrumentationRules/{autoInstrumentationRuleId}/Preview` (TriggerAutoInstrumentationPreview) +- `/v1/EventSources/{sourceId}/AutoInstrumentationRules/{autoInstrumentationRuleId}/Preview/{operationId}` (GetAutoInstrumentationPreviewResult) +- **Signal API** (`/v1/EventSources/…`): +- `/v1/EventSources/{sourceId}/Signals` (IngestSignals, ListSignals) +- `/v1/EventSources/{sourceId}/Signals/{signalKey}` (GetSignalBySignalKey) +- `/v1/EventSources/{sourceId}/SignalStats` (ListSignalStats) + +**Knowledge** +- ## 2026-07-20 +- **Content updates**: +- Added new schemas: `KnowledgeErrorInstance`, `KnowledgeErrorGroup` +- Added `errors` field to `WebSourceDetails` for reporting web crawl errors + +**Memory** +- ## 2026-08-18 +- **Breaking change**: +- Removed the deprecated `CSV` and `DATASET` values from the `DataMappingType` enum. +- `INGRESS`, `DATASET_CLOUDAPP`, and `DATASET_WAREHOUSE` are the only valid values now. +- Removed the `DataMappingFromCSV` and `DataMappingFromDataSet` schemas and their +- `oneOf`/discriminator entries on `DataMappingFromTypes`, along with the corresponding +- `CSV`/`DATASET` discriminator mapping keys. +- Any caller still sending `type: CSV` or `type: DATASET` on `AdminListDataMappings` +- (filtering by those values) will get a 400. +- ## 2026-08-10 +- No path changes (updated metadata only) +- `DataMappingType` gains `INGRESS`, `DATASET_CLOUDAPP`, and `DATASET_WAREHOUSE`. +- `CSV` and `DATASET` remain valid and unchanged; they are deprecated aliases and +- will be removed in a follow-up change. +- `DataMappingFromTypes` gains three `oneOf` members and three discriminator keys: +- `DataMappingFromIngress` (renames `DataMappingFromCSV`), +- `DataMappingFromCloudAppDataSet` and `DataMappingFromWarehouseDataSet` +- (both split from `DataMappingFromDataSet`, distinguishing a cloud-app-backed +- TDI dataset from a warehouse-backed one). +- Additive and backwards compatible: existing `CSV` and `DATASET` payloads are +- unaffected. +- ## 2026-08-27 +- **Added 2 new path(s)** for Trait Extraction Strategies: +- `/v1/ControlPlane/TraitExtractionStrategies` (ListTraitExtractionStrategies, CreateTraitExtractionStrategy) +- `/v1/ControlPlane/TraitExtractionStrategies/{traitStrategyId}` (FetchTraitExtractionStrategy, UpdateTraitExtractionStrategy, DeleteTraitExtractionStrategy) +- ## 2026-08-18 +- **Breaking change**: +- Removed the deprecated `CSV` and `DATASET` values from the `DataMappingType` enum. +- `INGRESS`, `DATASET_CLOUDAPP`, and `DATASET_WAREHOUSE` are the only valid values now. +- Removed the `DataMappingFromCSV` and `DataMappingFromDataSet` schemas and their +- `oneOf`/discriminator entries on `DataMappingFromTypes`, along with the corresponding +- `CSV`/`DATASET` discriminator mapping keys. +- Any caller still sending `type: CSV` or `type: DATASET` on `CreateDataMapping` or +- `UpdateDataMapping` (or filtering `ListDataMappings`/`ListDataMappingSuggestions` by +- those values) will get a 400. +- ## 2026-08-10 +- No path changes (updated metadata only) +- `DataMappingType` gains `INGRESS`, `DATASET_CLOUDAPP`, and `DATASET_WAREHOUSE`. +- `CSV` and `DATASET` remain valid and unchanged; they are deprecated aliases and +- will be removed in a follow-up change. +- `DataMappingFromTypes` gains three `oneOf` members and three discriminator keys: +- `DataMappingFromIngress` (renames `DataMappingFromCSV`), +- `DataMappingFromCloudAppDataSet` and `DataMappingFromWarehouseDataSet` +- (both split from `DataMappingFromDataSet`, distinguishing a cloud-app-backed +- TDI dataset from a warehouse-backed one). +- Additive and backwards compatible: existing `CSV` and `DATASET` payloads are +- unaffected. + +**Messaging** +- Add SenderIdentity, SenderType, and SenderRegion filter query parameters to list numbers and senders endpoint (beta) +- Add capabilities field to the numbers and senders response (beta) +- Remove the WhatsApp Senders v1 endpoints (`/v1/Channels/WhatsApp/Senders`) from RestProxy; the sender was routed to the sunsetting `messaging-whatsapp-k8s-orch` downstream. Use the Senders v2 API (`/v2/Channels/Senders`) instead. + +**Verify** +- Add `Templates` optional parameter on Verification creation (a stringified JSON array of `sid`/`substitutions` entries). When provided, `Templates` takes precedence over `TemplateSid`. + +**Voice** +- ## 2026-09-03 +- Added `links.conversation` to Transcription resources as the absolute Conversations API URL for the +- transcript's `conversationId`. It is present once the transcript has been stored; the `links` object +- is omitted otherwise. +- ## 2026-09-01 +- Removed `mediaUrl` from `CreateRequestWithMediaUrl`'s required fields so a request with neither `sourceId` nor `mediaUrl` reaches the downstream service, which rejects it with the specific error code 17500 instead of a generic gateway 400 +- Set `additionalProperties: false` on both `CreateRequestWithSourceId` and `CreateRequestWithMediaUrl` so the two `oneOf` variants stay mutually exclusive: `sourceId` is undeclared on the media-URL variant and `mediaUrl` is undeclared on the source-ID variant, keeping every request shape resolvable to exactly one variant +- ## 2026-08-05 +- Added GET /v3/Transcriptions to list and filter transcriptions (status, sourceId, languageCode, createdAfter/createdBefore) with pageSize/pageToken pagination. createdAfter is inclusive and createdBefore exclusive. Returns 422 (error code 17535) when a sourceId's historical item count exceeds the service scan cap + +**Webhooks** +- # API Changes +- ## 2026-08-24 +- **Changed**: Created Webhooks Config API ( https://docs.google.com/document/d/1zkAJD8a8MgoxWifdYDl_d465Az3W6CcD9fuCC2xlSXE/edit?tab=t.0#heading=h.u9e0ry6oe89j ), that includes 7 new resource(s)**: SharedKeys, AuthProfiles, Settings, Rules, Operations, Tests, EdgeZones in /v1/Webhooks referencing webhooks-config downstream. + + [2026-08-11] Version 9.11.0 --------------------------- **Library - Fix** diff --git a/setup.py b/setup.py index c31508371..c131ece07 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ setup( name="twilio", - version="9.11.0", + version="9.11.1", 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 2ef30c7eb..0ab1f74eb 100644 --- a/twilio/__init__.py +++ b/twilio/__init__.py @@ -1,2 +1,2 @@ -__version_info__ = ("9", "11", "0") +__version_info__ = ("9", "11", "1") __version__ = ".".join(__version_info__) diff --git a/twilio/rest/api/v2010/account/message/__init__.py b/twilio/rest/api/v2010/account/message/__init__.py index 38182a2c9..7a0d2be7c 100644 --- a/twilio/rest/api/v2010/account/message/__init__.py +++ b/twilio/rest/api/v2010/account/message/__init__.py @@ -751,6 +751,7 @@ def _create( send_at: Union[datetime, object] = values.unset, send_as_mms: Union[bool, object] = values.unset, content_variables: Union[str, object] = values.unset, + message_intent: Union[str, object] = values.unset, risk_check: Union["MessageInstance.RiskCheck", object] = values.unset, from_: Union[str, object] = values.unset, fallback_from: Union[str, object] = values.unset, @@ -786,6 +787,7 @@ def _create( "SendAt": serialize.iso8601_datetime(send_at), "SendAsMms": serialize.boolean_to_string(send_as_mms), "ContentVariables": content_variables, + "MessageIntent": message_intent, "RiskCheck": risk_check, "From": from_, "FallbackFrom": fallback_from, @@ -829,6 +831,7 @@ def create( send_at: Union[datetime, object] = values.unset, send_as_mms: Union[bool, object] = values.unset, content_variables: Union[str, object] = values.unset, + message_intent: Union[str, object] = values.unset, risk_check: Union["MessageInstance.RiskCheck", object] = values.unset, from_: Union[str, object] = values.unset, fallback_from: Union[str, object] = values.unset, @@ -858,6 +861,7 @@ def create( :param send_at: The time that Twilio will send the message. Must be in ISO 8601 format. :param send_as_mms: If set to `true`, Twilio delivers the message as a single MMS message, regardless of the presence of media. :param content_variables: For [Content Editor/API](https://www.twilio.com/docs/content) only: Key-value pairs of [Template variables](https://www.twilio.com/docs/content/using-variables-with-content-api) and their substitution values. `content_sid` parameter must also be provided. If values are not defined in the `content_variables` parameter, the [Template's default placeholder values](https://www.twilio.com/docs/content/content-api-resources#create-templates) are used. + :param message_intent: :param risk_check: :param from_: The sender's Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), [Wireless SIM](https://www.twilio.com/docs/iot/wireless/programmable-wireless-send-machine-machine-sms-commands), [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g., `whatsapp:+15554449999`). The value of the `from` parameter must be a sender that is hosted within Twilio and belongs to the Account creating the Message. If you are using `messaging_service_sid`, this parameter can be empty (Twilio assigns a `from` value from the Messaging Service's Sender Pool) or you can provide a specific sender from your Sender Pool. :param fallback_from: A fallback SMS sender to use when the recipient cannot be reached over RCS. This parameter may only be used when also providing a [Messaging Service](https://twilio.com/docs/messaging/services) containing an RCS sender. The fallback SMS sender must be either a Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), or [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), hosted within Twilio and belong to the Account creating the Message. @@ -887,6 +891,7 @@ def create( send_at=send_at, send_as_mms=send_as_mms, content_variables=content_variables, + message_intent=message_intent, risk_check=risk_check, from_=from_, fallback_from=fallback_from, @@ -923,6 +928,7 @@ def create_with_http_info( send_at: Union[datetime, object] = values.unset, send_as_mms: Union[bool, object] = values.unset, content_variables: Union[str, object] = values.unset, + message_intent: Union[str, object] = values.unset, risk_check: Union["MessageInstance.RiskCheck", object] = values.unset, from_: Union[str, object] = values.unset, fallback_from: Union[str, object] = values.unset, @@ -952,6 +958,7 @@ def create_with_http_info( :param send_at: The time that Twilio will send the message. Must be in ISO 8601 format. :param send_as_mms: If set to `true`, Twilio delivers the message as a single MMS message, regardless of the presence of media. :param content_variables: For [Content Editor/API](https://www.twilio.com/docs/content) only: Key-value pairs of [Template variables](https://www.twilio.com/docs/content/using-variables-with-content-api) and their substitution values. `content_sid` parameter must also be provided. If values are not defined in the `content_variables` parameter, the [Template's default placeholder values](https://www.twilio.com/docs/content/content-api-resources#create-templates) are used. + :param message_intent: :param risk_check: :param from_: The sender's Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), [Wireless SIM](https://www.twilio.com/docs/iot/wireless/programmable-wireless-send-machine-machine-sms-commands), [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g., `whatsapp:+15554449999`). The value of the `from` parameter must be a sender that is hosted within Twilio and belongs to the Account creating the Message. If you are using `messaging_service_sid`, this parameter can be empty (Twilio assigns a `from` value from the Messaging Service's Sender Pool) or you can provide a specific sender from your Sender Pool. :param fallback_from: A fallback SMS sender to use when the recipient cannot be reached over RCS. This parameter may only be used when also providing a [Messaging Service](https://twilio.com/docs/messaging/services) containing an RCS sender. The fallback SMS sender must be either a Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), or [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), hosted within Twilio and belong to the Account creating the Message. @@ -981,6 +988,7 @@ def create_with_http_info( send_at=send_at, send_as_mms=send_as_mms, content_variables=content_variables, + message_intent=message_intent, risk_check=risk_check, from_=from_, fallback_from=fallback_from, @@ -1018,6 +1026,7 @@ async def _create_async( send_at: Union[datetime, object] = values.unset, send_as_mms: Union[bool, object] = values.unset, content_variables: Union[str, object] = values.unset, + message_intent: Union[str, object] = values.unset, risk_check: Union["MessageInstance.RiskCheck", object] = values.unset, from_: Union[str, object] = values.unset, fallback_from: Union[str, object] = values.unset, @@ -1053,6 +1062,7 @@ async def _create_async( "SendAt": serialize.iso8601_datetime(send_at), "SendAsMms": serialize.boolean_to_string(send_as_mms), "ContentVariables": content_variables, + "MessageIntent": message_intent, "RiskCheck": risk_check, "From": from_, "FallbackFrom": fallback_from, @@ -1096,6 +1106,7 @@ async def create_async( send_at: Union[datetime, object] = values.unset, send_as_mms: Union[bool, object] = values.unset, content_variables: Union[str, object] = values.unset, + message_intent: Union[str, object] = values.unset, risk_check: Union["MessageInstance.RiskCheck", object] = values.unset, from_: Union[str, object] = values.unset, fallback_from: Union[str, object] = values.unset, @@ -1125,6 +1136,7 @@ async def create_async( :param send_at: The time that Twilio will send the message. Must be in ISO 8601 format. :param send_as_mms: If set to `true`, Twilio delivers the message as a single MMS message, regardless of the presence of media. :param content_variables: For [Content Editor/API](https://www.twilio.com/docs/content) only: Key-value pairs of [Template variables](https://www.twilio.com/docs/content/using-variables-with-content-api) and their substitution values. `content_sid` parameter must also be provided. If values are not defined in the `content_variables` parameter, the [Template's default placeholder values](https://www.twilio.com/docs/content/content-api-resources#create-templates) are used. + :param message_intent: :param risk_check: :param from_: The sender's Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), [Wireless SIM](https://www.twilio.com/docs/iot/wireless/programmable-wireless-send-machine-machine-sms-commands), [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g., `whatsapp:+15554449999`). The value of the `from` parameter must be a sender that is hosted within Twilio and belongs to the Account creating the Message. If you are using `messaging_service_sid`, this parameter can be empty (Twilio assigns a `from` value from the Messaging Service's Sender Pool) or you can provide a specific sender from your Sender Pool. :param fallback_from: A fallback SMS sender to use when the recipient cannot be reached over RCS. This parameter may only be used when also providing a [Messaging Service](https://twilio.com/docs/messaging/services) containing an RCS sender. The fallback SMS sender must be either a Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), or [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), hosted within Twilio and belong to the Account creating the Message. @@ -1154,6 +1166,7 @@ async def create_async( send_at=send_at, send_as_mms=send_as_mms, content_variables=content_variables, + message_intent=message_intent, risk_check=risk_check, from_=from_, fallback_from=fallback_from, @@ -1190,6 +1203,7 @@ async def create_with_http_info_async( send_at: Union[datetime, object] = values.unset, send_as_mms: Union[bool, object] = values.unset, content_variables: Union[str, object] = values.unset, + message_intent: Union[str, object] = values.unset, risk_check: Union["MessageInstance.RiskCheck", object] = values.unset, from_: Union[str, object] = values.unset, fallback_from: Union[str, object] = values.unset, @@ -1219,6 +1233,7 @@ async def create_with_http_info_async( :param send_at: The time that Twilio will send the message. Must be in ISO 8601 format. :param send_as_mms: If set to `true`, Twilio delivers the message as a single MMS message, regardless of the presence of media. :param content_variables: For [Content Editor/API](https://www.twilio.com/docs/content) only: Key-value pairs of [Template variables](https://www.twilio.com/docs/content/using-variables-with-content-api) and their substitution values. `content_sid` parameter must also be provided. If values are not defined in the `content_variables` parameter, the [Template's default placeholder values](https://www.twilio.com/docs/content/content-api-resources#create-templates) are used. + :param message_intent: :param risk_check: :param from_: The sender's Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), [Wireless SIM](https://www.twilio.com/docs/iot/wireless/programmable-wireless-send-machine-machine-sms-commands), [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g., `whatsapp:+15554449999`). The value of the `from` parameter must be a sender that is hosted within Twilio and belongs to the Account creating the Message. If you are using `messaging_service_sid`, this parameter can be empty (Twilio assigns a `from` value from the Messaging Service's Sender Pool) or you can provide a specific sender from your Sender Pool. :param fallback_from: A fallback SMS sender to use when the recipient cannot be reached over RCS. This parameter may only be used when also providing a [Messaging Service](https://twilio.com/docs/messaging/services) containing an RCS sender. The fallback SMS sender must be either a Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), or [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), hosted within Twilio and belong to the Account creating the Message. @@ -1248,6 +1263,7 @@ async def create_with_http_info_async( send_at=send_at, send_as_mms=send_as_mms, content_variables=content_variables, + message_intent=message_intent, risk_check=risk_check, from_=from_, fallback_from=fallback_from, diff --git a/twilio/rest/bulkexports/v1/export/export_custom_job.py b/twilio/rest/bulkexports/v1/export/export_custom_job.py index dee11094c..1dbd84c24 100644 --- a/twilio/rest/bulkexports/v1/export/export_custom_job.py +++ b/twilio/rest/bulkexports/v1/export/export_custom_job.py @@ -48,7 +48,9 @@ def __init__(self, version: Version, payload: Dict[str, Any], resource_type: str self.webhook_method: Optional[str] = payload.get("webhook_method") self.email: Optional[str] = payload.get("email") self.job_sid: Optional[str] = payload.get("job_sid") - self.details: Optional[List[Dict[str, object]]] = payload.get("details") + self.details: Optional[List[Dict[str, Dict[str, object]]]] = payload.get( + "details" + ) self.job_queue_position: Optional[str] = payload.get("job_queue_position") self.estimated_completion_time: Optional[str] = payload.get( "estimated_completion_time" diff --git a/twilio/rest/content/v1/content/__init__.py b/twilio/rest/content/v1/content/__init__.py index 3e38e775a..c0673c70a 100644 --- a/twilio/rest/content/v1/content/__init__.py +++ b/twilio/rest/content/v1/content/__init__.py @@ -152,8 +152,13 @@ def __init__(self, payload: Dict[str, Any]): self.title: Optional[str] = payload.get("title") self.body: Optional[str] = payload.get("body") self.media: Optional[str] = payload.get("media") - self.actions: Optional[List[ContentList.CarouselAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CarouselAction]] = ( + [ + ContentList.CarouselAction(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -210,7 +215,11 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.variables: Optional[Dict[str, str]] = payload.get("variables") self.language: Optional[str] = payload.get("language") - self.types: Optional[ContentList.Types] = payload.get("types") + self.types: Optional[ContentList.Types] = ( + ContentList.Types(payload.get("types")) + if payload.get("types") is not None + else None + ) def to_dict(self): return { @@ -233,7 +242,11 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.variables: Optional[Dict[str, str]] = payload.get("variables") self.language: Optional[str] = payload.get("language") - self.types: Optional[ContentList.Types] = payload.get("types") + self.types: Optional[ContentList.Types] = ( + ContentList.Types(payload.get("types")) + if payload.get("types") is not None + else None + ) def to_dict(self): return { @@ -258,8 +271,17 @@ def __init__(self, payload: Dict[str, Any]): self.next_page_id: Optional[str] = payload.get("next_page_id") self.title: Optional[str] = payload.get("title") self.subtitle: Optional[str] = payload.get("subtitle") - self.layout: Optional[List[ContentList.FlowsPageComponent]] = payload.get( - "layout" + self.layout: Optional[List[ContentList.FlowsPageComponent]] = ( + [ + ( + ContentList.FlowsPageComponent(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("layout") + ] + if payload.get("layout") is not None + else None ) def to_dict(self): @@ -343,8 +365,17 @@ class TwilioCallToAction(object): def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") - self.actions: Optional[List[ContentList.CallToActionAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CallToActionAction]] = ( + [ + ( + ContentList.CallToActionAction(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -370,8 +401,13 @@ def __init__(self, payload: Dict[str, Any]): self.title: Optional[str] = payload.get("title") self.subtitle: Optional[str] = payload.get("subtitle") self.media: Optional[List[str]] = payload.get("media") - self.actions: Optional[List[ContentList.CardAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CardAction]] = ( + [ + ContentList.CardAction(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -395,7 +431,14 @@ class TwilioCarousel(object): def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") - self.cards: Optional[List[ContentList.CarouselCard]] = payload.get("cards") + self.cards: Optional[List[ContentList.CarouselCard]] = ( + [ + ContentList.CarouselCard(item) if isinstance(item, dict) else item + for item in payload.get("cards") + ] + if payload.get("cards") is not None + else None + ) def to_dict(self): return { @@ -423,7 +466,14 @@ def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") self.subtitle: Optional[str] = payload.get("subtitle") self.id: Optional[str] = payload.get("id") - self.items: Optional[List[ContentList.CatalogItem]] = payload.get("items") + self.items: Optional[List[ContentList.CatalogItem]] = ( + [ + ContentList.CatalogItem(item) if isinstance(item, dict) else item + for item in payload.get("items") + ] + if payload.get("items") is not None + else None + ) self.dynamic_items: Optional[str] = payload.get("dynamic_items") def to_dict(self): @@ -456,7 +506,14 @@ def __init__(self, payload: Dict[str, Any]): self.button_text: Optional[str] = payload.get("button_text") self.subtitle: Optional[str] = payload.get("subtitle") self.media_url: Optional[str] = payload.get("media_url") - self.pages: Optional[List[ContentList.FlowsPage]] = payload.get("pages") + self.pages: Optional[List[ContentList.FlowsPage]] = ( + [ + ContentList.FlowsPage(item) if isinstance(item, dict) else item + for item in payload.get("pages") + ] + if payload.get("pages") is not None + else None + ) self.type: Optional[str] = payload.get("type") def to_dict(self): @@ -484,7 +541,14 @@ def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") self.button: Optional[str] = payload.get("button") - self.items: Optional[List[ContentList.ListItem]] = payload.get("items") + self.items: Optional[List[ContentList.ListItem]] = ( + [ + ContentList.ListItem(item) if isinstance(item, dict) else item + for item in payload.get("items") + ] + if payload.get("items") is not None + else None + ) def to_dict(self): return { @@ -549,8 +613,17 @@ class TwilioQuickReply(object): def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") - self.actions: Optional[List[ContentList.QuickReplyAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.QuickReplyAction]] = ( + [ + ( + ContentList.QuickReplyAction(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -617,47 +690,79 @@ class Types(object): def __init__(self, payload: Dict[str, Any]): - self.twilio_text: Optional[ContentList.TwilioText] = payload.get( - "twilio/text" + self.twilio_text: Optional[ContentList.TwilioText] = ( + ContentList.TwilioText(payload.get("twilio/text")) + if payload.get("twilio/text") is not None + else None ) - self.twilio_media: Optional[ContentList.TwilioMedia] = payload.get( - "twilio/media" + self.twilio_media: Optional[ContentList.TwilioMedia] = ( + ContentList.TwilioMedia(payload.get("twilio/media")) + if payload.get("twilio/media") is not None + else None ) - self.twilio_location: Optional[ContentList.TwilioLocation] = payload.get( - "twilio/location" + self.twilio_location: Optional[ContentList.TwilioLocation] = ( + ContentList.TwilioLocation(payload.get("twilio/location")) + if payload.get("twilio/location") is not None + else None ) self.twilio_list_picker: Optional[ContentList.TwilioListPicker] = ( - payload.get("twilio/list-picker") + ContentList.TwilioListPicker(payload.get("twilio/list-picker")) + if payload.get("twilio/list-picker") is not None + else None ) self.twilio_call_to_action: Optional[ContentList.TwilioCallToAction] = ( - payload.get("twilio/call-to-action") + ContentList.TwilioCallToAction(payload.get("twilio/call-to-action")) + if payload.get("twilio/call-to-action") is not None + else None ) self.twilio_quick_reply: Optional[ContentList.TwilioQuickReply] = ( - payload.get("twilio/quick-reply") - ) - self.twilio_card: Optional[ContentList.TwilioCard] = payload.get( - "twilio/card" - ) - self.twilio_catalog: Optional[ContentList.TwilioCatalog] = payload.get( - "twilio/catalog" - ) - self.twilio_carousel: Optional[ContentList.TwilioCarousel] = payload.get( - "twilio/carousel" - ) - self.twilio_flows: Optional[ContentList.TwilioFlows] = payload.get( - "twilio/flows" - ) - self.twilio_schedule: Optional[ContentList.TwilioSchedule] = payload.get( - "twilio/schedule" - ) - self.whatsapp_card: Optional[ContentList.WhatsappCard] = payload.get( - "whatsapp/card" + ContentList.TwilioQuickReply(payload.get("twilio/quick-reply")) + if payload.get("twilio/quick-reply") is not None + else None + ) + self.twilio_card: Optional[ContentList.TwilioCard] = ( + ContentList.TwilioCard(payload.get("twilio/card")) + if payload.get("twilio/card") is not None + else None + ) + self.twilio_catalog: Optional[ContentList.TwilioCatalog] = ( + ContentList.TwilioCatalog(payload.get("twilio/catalog")) + if payload.get("twilio/catalog") is not None + else None + ) + self.twilio_carousel: Optional[ContentList.TwilioCarousel] = ( + ContentList.TwilioCarousel(payload.get("twilio/carousel")) + if payload.get("twilio/carousel") is not None + else None + ) + self.twilio_flows: Optional[ContentList.TwilioFlows] = ( + ContentList.TwilioFlows(payload.get("twilio/flows")) + if payload.get("twilio/flows") is not None + else None + ) + self.twilio_schedule: Optional[ContentList.TwilioSchedule] = ( + ContentList.TwilioSchedule(payload.get("twilio/schedule")) + if payload.get("twilio/schedule") is not None + else None + ) + self.whatsapp_card: Optional[ContentList.WhatsappCard] = ( + ContentList.WhatsappCard(payload.get("whatsapp/card")) + if payload.get("whatsapp/card") is not None + else None ) self.whatsapp_authentication: Optional[ ContentList.WhatsappAuthentication - ] = payload.get("whatsapp/authentication") - self.whatsapp_flows: Optional[ContentList.WhatsappFlows] = payload.get( - "whatsapp/flows" + ] = ( + ContentList.WhatsappAuthentication( + payload.get("whatsapp/authentication") + ) + if payload.get("whatsapp/authentication") is not None + else None + ) + self.whatsapp_flows: Optional[ContentList.WhatsappFlows] = ( + ContentList.WhatsappFlows(payload.get("whatsapp/flows")) + if payload.get("whatsapp/flows") is not None + else None ) def to_dict(self): @@ -746,7 +851,16 @@ def __init__(self, payload: Dict[str, Any]): "code_expiration_minutes" ) self.actions: Optional[List[ContentList.AuthenticationAction]] = ( - payload.get("actions") + [ + ( + ContentList.AuthenticationAction(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -775,8 +889,13 @@ def __init__(self, payload: Dict[str, Any]): self.footer: Optional[str] = payload.get("footer") self.media: Optional[List[str]] = payload.get("media") self.header_text: Optional[str] = payload.get("header_text") - self.actions: Optional[List[ContentList.CardAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CardAction]] = ( + [ + ContentList.CardAction(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -1192,8 +1311,13 @@ def __init__(self, payload: Dict[str, Any]): self.title: Optional[str] = payload.get("title") self.body: Optional[str] = payload.get("body") self.media: Optional[str] = payload.get("media") - self.actions: Optional[List[ContentList.CarouselAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CarouselAction]] = ( + [ + ContentList.CarouselAction(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -1250,7 +1374,11 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.variables: Optional[Dict[str, str]] = payload.get("variables") self.language: Optional[str] = payload.get("language") - self.types: Optional[ContentList.Types] = payload.get("types") + self.types: Optional[ContentList.Types] = ( + ContentList.Types(payload.get("types")) + if payload.get("types") is not None + else None + ) def to_dict(self): return { @@ -1273,7 +1401,11 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.variables: Optional[Dict[str, str]] = payload.get("variables") self.language: Optional[str] = payload.get("language") - self.types: Optional[ContentList.Types] = payload.get("types") + self.types: Optional[ContentList.Types] = ( + ContentList.Types(payload.get("types")) + if payload.get("types") is not None + else None + ) def to_dict(self): return { @@ -1298,8 +1430,17 @@ def __init__(self, payload: Dict[str, Any]): self.next_page_id: Optional[str] = payload.get("next_page_id") self.title: Optional[str] = payload.get("title") self.subtitle: Optional[str] = payload.get("subtitle") - self.layout: Optional[List[ContentList.FlowsPageComponent]] = payload.get( - "layout" + self.layout: Optional[List[ContentList.FlowsPageComponent]] = ( + [ + ( + ContentList.FlowsPageComponent(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("layout") + ] + if payload.get("layout") is not None + else None ) def to_dict(self): @@ -1383,8 +1524,17 @@ class TwilioCallToAction(object): def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") - self.actions: Optional[List[ContentList.CallToActionAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CallToActionAction]] = ( + [ + ( + ContentList.CallToActionAction(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -1410,8 +1560,13 @@ def __init__(self, payload: Dict[str, Any]): self.title: Optional[str] = payload.get("title") self.subtitle: Optional[str] = payload.get("subtitle") self.media: Optional[List[str]] = payload.get("media") - self.actions: Optional[List[ContentList.CardAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CardAction]] = ( + [ + ContentList.CardAction(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -1435,7 +1590,14 @@ class TwilioCarousel(object): def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") - self.cards: Optional[List[ContentList.CarouselCard]] = payload.get("cards") + self.cards: Optional[List[ContentList.CarouselCard]] = ( + [ + ContentList.CarouselCard(item) if isinstance(item, dict) else item + for item in payload.get("cards") + ] + if payload.get("cards") is not None + else None + ) def to_dict(self): return { @@ -1463,7 +1625,14 @@ def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") self.subtitle: Optional[str] = payload.get("subtitle") self.id: Optional[str] = payload.get("id") - self.items: Optional[List[ContentList.CatalogItem]] = payload.get("items") + self.items: Optional[List[ContentList.CatalogItem]] = ( + [ + ContentList.CatalogItem(item) if isinstance(item, dict) else item + for item in payload.get("items") + ] + if payload.get("items") is not None + else None + ) self.dynamic_items: Optional[str] = payload.get("dynamic_items") def to_dict(self): @@ -1496,7 +1665,14 @@ def __init__(self, payload: Dict[str, Any]): self.button_text: Optional[str] = payload.get("button_text") self.subtitle: Optional[str] = payload.get("subtitle") self.media_url: Optional[str] = payload.get("media_url") - self.pages: Optional[List[ContentList.FlowsPage]] = payload.get("pages") + self.pages: Optional[List[ContentList.FlowsPage]] = ( + [ + ContentList.FlowsPage(item) if isinstance(item, dict) else item + for item in payload.get("pages") + ] + if payload.get("pages") is not None + else None + ) self.type: Optional[str] = payload.get("type") def to_dict(self): @@ -1524,7 +1700,14 @@ def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") self.button: Optional[str] = payload.get("button") - self.items: Optional[List[ContentList.ListItem]] = payload.get("items") + self.items: Optional[List[ContentList.ListItem]] = ( + [ + ContentList.ListItem(item) if isinstance(item, dict) else item + for item in payload.get("items") + ] + if payload.get("items") is not None + else None + ) def to_dict(self): return { @@ -1589,8 +1772,17 @@ class TwilioQuickReply(object): def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") - self.actions: Optional[List[ContentList.QuickReplyAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.QuickReplyAction]] = ( + [ + ( + ContentList.QuickReplyAction(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -1657,47 +1849,79 @@ class Types(object): def __init__(self, payload: Dict[str, Any]): - self.twilio_text: Optional[ContentList.TwilioText] = payload.get( - "twilio/text" + self.twilio_text: Optional[ContentList.TwilioText] = ( + ContentList.TwilioText(payload.get("twilio/text")) + if payload.get("twilio/text") is not None + else None ) - self.twilio_media: Optional[ContentList.TwilioMedia] = payload.get( - "twilio/media" + self.twilio_media: Optional[ContentList.TwilioMedia] = ( + ContentList.TwilioMedia(payload.get("twilio/media")) + if payload.get("twilio/media") is not None + else None ) - self.twilio_location: Optional[ContentList.TwilioLocation] = payload.get( - "twilio/location" + self.twilio_location: Optional[ContentList.TwilioLocation] = ( + ContentList.TwilioLocation(payload.get("twilio/location")) + if payload.get("twilio/location") is not None + else None ) self.twilio_list_picker: Optional[ContentList.TwilioListPicker] = ( - payload.get("twilio/list-picker") + ContentList.TwilioListPicker(payload.get("twilio/list-picker")) + if payload.get("twilio/list-picker") is not None + else None ) self.twilio_call_to_action: Optional[ContentList.TwilioCallToAction] = ( - payload.get("twilio/call-to-action") + ContentList.TwilioCallToAction(payload.get("twilio/call-to-action")) + if payload.get("twilio/call-to-action") is not None + else None ) self.twilio_quick_reply: Optional[ContentList.TwilioQuickReply] = ( - payload.get("twilio/quick-reply") - ) - self.twilio_card: Optional[ContentList.TwilioCard] = payload.get( - "twilio/card" - ) - self.twilio_catalog: Optional[ContentList.TwilioCatalog] = payload.get( - "twilio/catalog" - ) - self.twilio_carousel: Optional[ContentList.TwilioCarousel] = payload.get( - "twilio/carousel" - ) - self.twilio_flows: Optional[ContentList.TwilioFlows] = payload.get( - "twilio/flows" - ) - self.twilio_schedule: Optional[ContentList.TwilioSchedule] = payload.get( - "twilio/schedule" - ) - self.whatsapp_card: Optional[ContentList.WhatsappCard] = payload.get( - "whatsapp/card" + ContentList.TwilioQuickReply(payload.get("twilio/quick-reply")) + if payload.get("twilio/quick-reply") is not None + else None + ) + self.twilio_card: Optional[ContentList.TwilioCard] = ( + ContentList.TwilioCard(payload.get("twilio/card")) + if payload.get("twilio/card") is not None + else None + ) + self.twilio_catalog: Optional[ContentList.TwilioCatalog] = ( + ContentList.TwilioCatalog(payload.get("twilio/catalog")) + if payload.get("twilio/catalog") is not None + else None + ) + self.twilio_carousel: Optional[ContentList.TwilioCarousel] = ( + ContentList.TwilioCarousel(payload.get("twilio/carousel")) + if payload.get("twilio/carousel") is not None + else None + ) + self.twilio_flows: Optional[ContentList.TwilioFlows] = ( + ContentList.TwilioFlows(payload.get("twilio/flows")) + if payload.get("twilio/flows") is not None + else None + ) + self.twilio_schedule: Optional[ContentList.TwilioSchedule] = ( + ContentList.TwilioSchedule(payload.get("twilio/schedule")) + if payload.get("twilio/schedule") is not None + else None + ) + self.whatsapp_card: Optional[ContentList.WhatsappCard] = ( + ContentList.WhatsappCard(payload.get("whatsapp/card")) + if payload.get("whatsapp/card") is not None + else None ) self.whatsapp_authentication: Optional[ ContentList.WhatsappAuthentication - ] = payload.get("whatsapp/authentication") - self.whatsapp_flows: Optional[ContentList.WhatsappFlows] = payload.get( - "whatsapp/flows" + ] = ( + ContentList.WhatsappAuthentication( + payload.get("whatsapp/authentication") + ) + if payload.get("whatsapp/authentication") is not None + else None + ) + self.whatsapp_flows: Optional[ContentList.WhatsappFlows] = ( + ContentList.WhatsappFlows(payload.get("whatsapp/flows")) + if payload.get("whatsapp/flows") is not None + else None ) def to_dict(self): @@ -1786,7 +2010,16 @@ def __init__(self, payload: Dict[str, Any]): "code_expiration_minutes" ) self.actions: Optional[List[ContentList.AuthenticationAction]] = ( - payload.get("actions") + [ + ( + ContentList.AuthenticationAction(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -1815,8 +2048,13 @@ def __init__(self, payload: Dict[str, Any]): self.footer: Optional[str] = payload.get("footer") self.media: Optional[List[str]] = payload.get("media") self.header_text: Optional[str] = payload.get("header_text") - self.actions: Optional[List[ContentList.CardAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CardAction]] = ( + [ + ContentList.CardAction(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -2324,8 +2562,13 @@ def __init__(self, payload: Dict[str, Any]): self.title: Optional[str] = payload.get("title") self.body: Optional[str] = payload.get("body") self.media: Optional[str] = payload.get("media") - self.actions: Optional[List[ContentList.CarouselAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CarouselAction]] = ( + [ + ContentList.CarouselAction(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -2382,7 +2625,11 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.variables: Optional[Dict[str, str]] = payload.get("variables") self.language: Optional[str] = payload.get("language") - self.types: Optional[ContentList.Types] = payload.get("types") + self.types: Optional[ContentList.Types] = ( + ContentList.Types(payload.get("types")) + if payload.get("types") is not None + else None + ) def to_dict(self): return { @@ -2405,7 +2652,11 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.variables: Optional[Dict[str, str]] = payload.get("variables") self.language: Optional[str] = payload.get("language") - self.types: Optional[ContentList.Types] = payload.get("types") + self.types: Optional[ContentList.Types] = ( + ContentList.Types(payload.get("types")) + if payload.get("types") is not None + else None + ) def to_dict(self): return { @@ -2430,8 +2681,17 @@ def __init__(self, payload: Dict[str, Any]): self.next_page_id: Optional[str] = payload.get("next_page_id") self.title: Optional[str] = payload.get("title") self.subtitle: Optional[str] = payload.get("subtitle") - self.layout: Optional[List[ContentList.FlowsPageComponent]] = payload.get( - "layout" + self.layout: Optional[List[ContentList.FlowsPageComponent]] = ( + [ + ( + ContentList.FlowsPageComponent(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("layout") + ] + if payload.get("layout") is not None + else None ) def to_dict(self): @@ -2515,8 +2775,17 @@ class TwilioCallToAction(object): def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") - self.actions: Optional[List[ContentList.CallToActionAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CallToActionAction]] = ( + [ + ( + ContentList.CallToActionAction(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -2542,8 +2811,13 @@ def __init__(self, payload: Dict[str, Any]): self.title: Optional[str] = payload.get("title") self.subtitle: Optional[str] = payload.get("subtitle") self.media: Optional[List[str]] = payload.get("media") - self.actions: Optional[List[ContentList.CardAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CardAction]] = ( + [ + ContentList.CardAction(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -2567,7 +2841,14 @@ class TwilioCarousel(object): def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") - self.cards: Optional[List[ContentList.CarouselCard]] = payload.get("cards") + self.cards: Optional[List[ContentList.CarouselCard]] = ( + [ + ContentList.CarouselCard(item) if isinstance(item, dict) else item + for item in payload.get("cards") + ] + if payload.get("cards") is not None + else None + ) def to_dict(self): return { @@ -2595,7 +2876,14 @@ def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") self.subtitle: Optional[str] = payload.get("subtitle") self.id: Optional[str] = payload.get("id") - self.items: Optional[List[ContentList.CatalogItem]] = payload.get("items") + self.items: Optional[List[ContentList.CatalogItem]] = ( + [ + ContentList.CatalogItem(item) if isinstance(item, dict) else item + for item in payload.get("items") + ] + if payload.get("items") is not None + else None + ) self.dynamic_items: Optional[str] = payload.get("dynamic_items") def to_dict(self): @@ -2628,7 +2916,14 @@ def __init__(self, payload: Dict[str, Any]): self.button_text: Optional[str] = payload.get("button_text") self.subtitle: Optional[str] = payload.get("subtitle") self.media_url: Optional[str] = payload.get("media_url") - self.pages: Optional[List[ContentList.FlowsPage]] = payload.get("pages") + self.pages: Optional[List[ContentList.FlowsPage]] = ( + [ + ContentList.FlowsPage(item) if isinstance(item, dict) else item + for item in payload.get("pages") + ] + if payload.get("pages") is not None + else None + ) self.type: Optional[str] = payload.get("type") def to_dict(self): @@ -2656,7 +2951,14 @@ def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") self.button: Optional[str] = payload.get("button") - self.items: Optional[List[ContentList.ListItem]] = payload.get("items") + self.items: Optional[List[ContentList.ListItem]] = ( + [ + ContentList.ListItem(item) if isinstance(item, dict) else item + for item in payload.get("items") + ] + if payload.get("items") is not None + else None + ) def to_dict(self): return { @@ -2721,8 +3023,17 @@ class TwilioQuickReply(object): def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") - self.actions: Optional[List[ContentList.QuickReplyAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.QuickReplyAction]] = ( + [ + ( + ContentList.QuickReplyAction(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -2789,47 +3100,79 @@ class Types(object): def __init__(self, payload: Dict[str, Any]): - self.twilio_text: Optional[ContentList.TwilioText] = payload.get( - "twilio/text" + self.twilio_text: Optional[ContentList.TwilioText] = ( + ContentList.TwilioText(payload.get("twilio/text")) + if payload.get("twilio/text") is not None + else None ) - self.twilio_media: Optional[ContentList.TwilioMedia] = payload.get( - "twilio/media" + self.twilio_media: Optional[ContentList.TwilioMedia] = ( + ContentList.TwilioMedia(payload.get("twilio/media")) + if payload.get("twilio/media") is not None + else None ) - self.twilio_location: Optional[ContentList.TwilioLocation] = payload.get( - "twilio/location" + self.twilio_location: Optional[ContentList.TwilioLocation] = ( + ContentList.TwilioLocation(payload.get("twilio/location")) + if payload.get("twilio/location") is not None + else None ) self.twilio_list_picker: Optional[ContentList.TwilioListPicker] = ( - payload.get("twilio/list-picker") + ContentList.TwilioListPicker(payload.get("twilio/list-picker")) + if payload.get("twilio/list-picker") is not None + else None ) self.twilio_call_to_action: Optional[ContentList.TwilioCallToAction] = ( - payload.get("twilio/call-to-action") + ContentList.TwilioCallToAction(payload.get("twilio/call-to-action")) + if payload.get("twilio/call-to-action") is not None + else None ) self.twilio_quick_reply: Optional[ContentList.TwilioQuickReply] = ( - payload.get("twilio/quick-reply") - ) - self.twilio_card: Optional[ContentList.TwilioCard] = payload.get( - "twilio/card" - ) - self.twilio_catalog: Optional[ContentList.TwilioCatalog] = payload.get( - "twilio/catalog" - ) - self.twilio_carousel: Optional[ContentList.TwilioCarousel] = payload.get( - "twilio/carousel" - ) - self.twilio_flows: Optional[ContentList.TwilioFlows] = payload.get( - "twilio/flows" - ) - self.twilio_schedule: Optional[ContentList.TwilioSchedule] = payload.get( - "twilio/schedule" - ) - self.whatsapp_card: Optional[ContentList.WhatsappCard] = payload.get( - "whatsapp/card" + ContentList.TwilioQuickReply(payload.get("twilio/quick-reply")) + if payload.get("twilio/quick-reply") is not None + else None + ) + self.twilio_card: Optional[ContentList.TwilioCard] = ( + ContentList.TwilioCard(payload.get("twilio/card")) + if payload.get("twilio/card") is not None + else None + ) + self.twilio_catalog: Optional[ContentList.TwilioCatalog] = ( + ContentList.TwilioCatalog(payload.get("twilio/catalog")) + if payload.get("twilio/catalog") is not None + else None + ) + self.twilio_carousel: Optional[ContentList.TwilioCarousel] = ( + ContentList.TwilioCarousel(payload.get("twilio/carousel")) + if payload.get("twilio/carousel") is not None + else None + ) + self.twilio_flows: Optional[ContentList.TwilioFlows] = ( + ContentList.TwilioFlows(payload.get("twilio/flows")) + if payload.get("twilio/flows") is not None + else None + ) + self.twilio_schedule: Optional[ContentList.TwilioSchedule] = ( + ContentList.TwilioSchedule(payload.get("twilio/schedule")) + if payload.get("twilio/schedule") is not None + else None + ) + self.whatsapp_card: Optional[ContentList.WhatsappCard] = ( + ContentList.WhatsappCard(payload.get("whatsapp/card")) + if payload.get("whatsapp/card") is not None + else None ) self.whatsapp_authentication: Optional[ ContentList.WhatsappAuthentication - ] = payload.get("whatsapp/authentication") - self.whatsapp_flows: Optional[ContentList.WhatsappFlows] = payload.get( - "whatsapp/flows" + ] = ( + ContentList.WhatsappAuthentication( + payload.get("whatsapp/authentication") + ) + if payload.get("whatsapp/authentication") is not None + else None + ) + self.whatsapp_flows: Optional[ContentList.WhatsappFlows] = ( + ContentList.WhatsappFlows(payload.get("whatsapp/flows")) + if payload.get("whatsapp/flows") is not None + else None ) def to_dict(self): @@ -2918,7 +3261,16 @@ def __init__(self, payload: Dict[str, Any]): "code_expiration_minutes" ) self.actions: Optional[List[ContentList.AuthenticationAction]] = ( - payload.get("actions") + [ + ( + ContentList.AuthenticationAction(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -2947,8 +3299,13 @@ def __init__(self, payload: Dict[str, Any]): self.footer: Optional[str] = payload.get("footer") self.media: Optional[List[str]] = payload.get("media") self.header_text: Optional[str] = payload.get("header_text") - self.actions: Optional[List[ContentList.CardAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CardAction]] = ( + [ + ContentList.CardAction(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): diff --git a/twilio/rest/content/v1/content/approval_create.py b/twilio/rest/content/v1/content/approval_create.py index 2487ec609..cfb7b88bf 100644 --- a/twilio/rest/content/v1/content/approval_create.py +++ b/twilio/rest/content/v1/content/approval_create.py @@ -27,17 +27,20 @@ class ContentApprovalRequest(object): """ :ivar name: Name of the template. :ivar category: A WhatsApp recognized template category. + :ivar send_ttl_seconds: Time-to-live in seconds for attempting to send a message with this Content """ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.category: Optional[str] = payload.get("category") + self.send_ttl_seconds: Optional[int] = payload.get("send_ttl_seconds") def to_dict(self): return { "name": self.name, "category": self.category, + "send_ttl_seconds": self.send_ttl_seconds, } """ @@ -47,6 +50,7 @@ def to_dict(self): :ivar status: :ivar rejection_reason: :ivar allow_category_change: + :ivar send_ttl_seconds: Time-to-live in seconds for attempting to send a message with this Content """ def __init__(self, version: Version, payload: Dict[str, Any], content_sid: str): @@ -60,6 +64,7 @@ def __init__(self, version: Version, payload: Dict[str, Any], content_sid: str): self.allow_category_change: Optional[bool] = payload.get( "allow_category_change" ) + self.send_ttl_seconds: Optional[int] = payload.get("send_ttl_seconds") self._solution = { "content_sid": content_sid, @@ -81,17 +86,20 @@ class ContentApprovalRequest(object): """ :ivar name: Name of the template. :ivar category: A WhatsApp recognized template category. + :ivar send_ttl_seconds: Time-to-live in seconds for attempting to send a message with this Content """ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.category: Optional[str] = payload.get("category") + self.send_ttl_seconds: Optional[int] = payload.get("send_ttl_seconds") def to_dict(self): return { "name": self.name, "category": self.category, + "send_ttl_seconds": self.send_ttl_seconds, } def __init__(self, version: Version, content_sid: str): diff --git a/twilio/rest/conversations/v1/conversation/message/__init__.py b/twilio/rest/conversations/v1/conversation/message/__init__.py index 947d8f466..4b812e473 100644 --- a/twilio/rest/conversations/v1/conversation/message/__init__.py +++ b/twilio/rest/conversations/v1/conversation/message/__init__.py @@ -69,7 +69,9 @@ def __init__( self.index: Optional[int] = deserialize.integer(payload.get("index")) self.author: Optional[str] = payload.get("author") self.body: Optional[str] = payload.get("body") - self.media: Optional[List[Dict[str, object]]] = payload.get("media") + self.media: Optional[ + List[Dict[str, Dict[str, Dict[str, Dict[str, object]]]]] + ] = payload.get("media") self.attributes: Optional[str] = payload.get("attributes") self.participant_sid: Optional[str] = payload.get("participant_sid") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( diff --git a/twilio/rest/conversations/v1/service/conversation/message/__init__.py b/twilio/rest/conversations/v1/service/conversation/message/__init__.py index 1ae1acbaf..c38479e2b 100644 --- a/twilio/rest/conversations/v1/service/conversation/message/__init__.py +++ b/twilio/rest/conversations/v1/service/conversation/message/__init__.py @@ -72,7 +72,9 @@ def __init__( self.index: Optional[int] = deserialize.integer(payload.get("index")) self.author: Optional[str] = payload.get("author") self.body: Optional[str] = payload.get("body") - self.media: Optional[List[Dict[str, object]]] = payload.get("media") + self.media: Optional[ + List[Dict[str, Dict[str, Dict[str, Dict[str, object]]]]] + ] = payload.get("media") self.attributes: Optional[str] = payload.get("attributes") self.participant_sid: Optional[str] = payload.get("participant_sid") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( diff --git a/twilio/rest/conversations/v2/action.py b/twilio/rest/conversations/v2/action.py index 6f907b17d..b09e961c2 100644 --- a/twilio/rest/conversations/v2/action.py +++ b/twilio/rest/conversations/v2/action.py @@ -37,6 +37,7 @@ class ConversationsV2Channel(object): RCS = "RCS" WHATSAPP = "WHATSAPP" CHAT = "CHAT" + VIDEO = "VIDEO" """ :ivar id: Unique identifier for this Action. @@ -60,7 +61,9 @@ def __init__( self.id: Optional[str] = payload.get("id") self.type: Optional[str] = payload.get("type") - self.status: Optional["ActionInstance.str"] = payload.get("status") + self.status: Optional["ActionInstance.ConversationsV2ActionStatus"] = ( + payload.get("status") + ) self.conversation_id: Optional[str] = payload.get("conversationId") self.related: Optional[Dict[str, str]] = payload.get("related") self.created_at: Optional[datetime] = deserialize.iso8601_datetime( @@ -327,15 +330,30 @@ class ConversationsV2SendMessagePayload(object): def __init__(self, payload: Dict[str, Any]): self._from: Optional[ActionList.ConversationsV2SendMessageParticipant] = ( - payload.get("from") + ActionList.ConversationsV2SendMessageParticipant(payload.get("from")) + if payload.get("from") is not None + else None ) self.to: Optional[ List[ActionList.ConversationsV2SendMessageParticipant] - ] = payload.get("to") + ] = ( + [ + ( + ActionList.ConversationsV2SendMessageParticipant(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("to") + ] + if payload.get("to") is not None + else None + ) self.content: Optional[ActionList.ConversationsV2SendMessageContent] = ( - payload.get("content") + ActionList.ConversationsV2SendMessageContent(payload.get("content")) + if payload.get("content") is not None + else None ) - self.channel_settings: Optional[Dict[str, object]] = payload.get( + self.channel_settings: Optional[Dict[str, Dict[str, object]]] = payload.get( "channelSettings" ) @@ -357,7 +375,9 @@ def __init__(self, payload: Dict[str, Any]): self.type: Optional[str] = payload.get("type") self.payload: Optional[ActionList.ConversationsV2SendMessagePayload] = ( - payload.get("payload") + ActionList.ConversationsV2SendMessagePayload(payload.get("payload")) + if payload.get("payload") is not None + else None ) def to_dict(self): diff --git a/twilio/rest/conversations/v2/communication.py b/twilio/rest/conversations/v2/communication.py index adecbdd95..299490962 100644 --- a/twilio/rest/conversations/v2/communication.py +++ b/twilio/rest/conversations/v2/communication.py @@ -33,11 +33,13 @@ class ConversationsV2Channel(object): RCS = "RCS" WHATSAPP = "WHATSAPP" CHAT = "CHAT" + VIDEO = "VIDEO" class ConversationsV2RecipientDeliveryStatus(object): INITIATED = "INITIATED" IN_PROGRESS = "IN_PROGRESS" DELIVERED = "DELIVERED" + READ = "READ" COMPLETED = "COMPLETED" FAILED = "FAILED" @@ -337,7 +339,18 @@ def __init__(self, payload: Dict[str, Any]): self.engine: Optional[str] = payload.get("engine") self.words: Optional[ List[ConversationsV2ContentTranscriptionTranscriptionWords] - ] = payload.get("words") + ] = ( + [ + ( + ConversationsV2ContentTranscriptionTranscriptionWords(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("words") + ] + if payload.get("words") is not None + else None + ) def to_dict(self): return { @@ -384,16 +397,41 @@ def __init__(self, payload: Dict[str, Any]): self.author: Optional[ CommunicationList.CreateCommunicationInConversationRequestAuthor - ] = payload.get("author") + ] = ( + CommunicationList.CreateCommunicationInConversationRequestAuthor( + payload.get("author") + ) + if payload.get("author") is not None + else None + ) self.content: Optional[ CommunicationList.CreateCommunicationInConversationRequestContent - ] = payload.get("content") + ] = ( + CommunicationList.CreateCommunicationInConversationRequestContent( + payload.get("content") + ) + if payload.get("content") is not None + else None + ) self.channel_id: Optional[str] = payload.get("channelId") self.recipients: Optional[ List[ CommunicationList.CreateCommunicationInConversationRequestRecipients ] - ] = payload.get("recipients") + ] = ( + [ + ( + CommunicationList.CreateCommunicationInConversationRequestRecipients( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("recipients") + ] + if payload.get("recipients") is not None + else None + ) self.occurred_at: Optional[datetime] = payload.get("occurredAt") def to_dict(self): @@ -419,7 +457,7 @@ class CreateCommunicationInConversationRequestAuthor(object): def __init__(self, payload: Dict[str, Any]): self.address: Optional[str] = payload.get("address") - self.channel: Optional["CommunicationInstance.str"] = payload.get("channel") + self.channel: Optional[str] = payload.get("channel") self.participant_id: Optional[str] = payload.get("participantId") def to_dict(self): @@ -438,11 +476,17 @@ class CreateCommunicationInConversationRequestContent(object): def __init__(self, payload: Dict[str, Any]): - self.type: Optional["CommunicationInstance.str"] = payload.get("type") + self.type: Optional[str] = payload.get("type") self.text: Optional[str] = payload.get("text") self.transcription: Optional[ CommunicationList.ContentTranscriptionTranscription - ] = payload.get("transcription") + ] = ( + CommunicationList.ContentTranscriptionTranscription( + payload.get("transcription") + ) + if payload.get("transcription") is not None + else None + ) def to_dict(self): return { @@ -465,7 +509,7 @@ class CreateCommunicationInConversationRequestRecipients(object): def __init__(self, payload: Dict[str, Any]): self.address: Optional[str] = payload.get("address") - self.channel: Optional["CommunicationInstance.str"] = payload.get("channel") + self.channel: Optional[str] = payload.get("channel") self.participant_id: Optional[str] = payload.get("participantId") def to_dict(self): diff --git a/twilio/rest/conversations/v2/configuration.py b/twilio/rest/conversations/v2/configuration.py index fb481bcc4..84a67a9b4 100644 --- a/twilio/rest/conversations/v2/configuration.py +++ b/twilio/rest/conversations/v2/configuration.py @@ -53,7 +53,7 @@ class ConversationsV2ConversationGroupingType(object): """ def __init__( - self, version: Version, payload: ResponseResource, id: Optional[str] = None + self, version: Version, payload: Dict[str, Any], id: Optional[str] = None ): super().__init__(version) @@ -202,6 +202,46 @@ async def fetch_with_http_info_async(self) -> ApiResponse: """ return await self._proxy.fetch_with_http_info_async() + def patch( + self, + idempotency_key: Union[str, object] = values.unset, + patch_configuration_request: Union[ + PatchConfigurationRequest, object + ] = values.unset, + ) -> "ConfigurationInstance": + """ + Patch the ConfigurationInstance + + :param idempotency_key: Client-generated UUID key to ensure idempotent behavior. Submitting the same key returns the original response without creating a duplicate operation. Keys are scoped to account + region with a 24-hour TTL. + :param patch_configuration_request: The partial configuration update. + + :returns: The patched ConfigurationInstance + """ + return self._proxy.patch( + idempotency_key=idempotency_key, + patch_configuration_request=patch_configuration_request, + ) + + async def patch_async( + self, + idempotency_key: Union[str, object] = values.unset, + patch_configuration_request: Union[ + PatchConfigurationRequest, object + ] = values.unset, + ) -> "ConfigurationInstance": + """ + Asynchronous coroutine to patch the ConfigurationInstance + + :param idempotency_key: Client-generated UUID key to ensure idempotent behavior. Submitting the same key returns the original response without creating a duplicate operation. Keys are scoped to account + region with a 24-hour TTL. + :param patch_configuration_request: The partial configuration update. + + :returns: The patched ConfigurationInstance + """ + return await self._proxy.patch_async( + idempotency_key=idempotency_key, + patch_configuration_request=patch_configuration_request, + ) + def update( self, idempotency_key: Union[str, object] = values.unset, @@ -495,6 +535,158 @@ async def fetch_with_http_info_async(self) -> ApiResponse: ) return ApiResponse(data=instance, status_code=status_code, headers=headers) + def _patch( + self, + idempotency_key: Union[str, object] = values.unset, + patch_configuration_request: Union[ + PatchConfigurationRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal helper for patch operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = patch_configuration_request.to_dict() + + headers = values.of({}) + + if not ( + idempotency_key is values.unset + or (isinstance(idempotency_key, str) and not idempotency_key) + ): + headers["Idempotency-Key"] = idempotency_key + + 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, + idempotency_key: Union[str, object] = values.unset, + patch_configuration_request: Union[ + PatchConfigurationRequest, object + ] = values.unset, + ) -> ConfigurationInstance: + """ + Patch the ConfigurationInstance + + :param idempotency_key: Client-generated UUID key to ensure idempotent behavior. Submitting the same key returns the original response without creating a duplicate operation. Keys are scoped to account + region with a 24-hour TTL. + :param patch_configuration_request: The partial configuration update. + + :returns: The patched ConfigurationInstance + """ + payload, _, _ = self._patch( + idempotency_key=idempotency_key, + patch_configuration_request=patch_configuration_request, + ) + return ConfigurationInstance(self._version, payload, id=self._solution["id"]) + + def patch_with_http_info( + self, + idempotency_key: Union[str, object] = values.unset, + patch_configuration_request: Union[ + PatchConfigurationRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Patch the ConfigurationInstance and return response metadata + + :param idempotency_key: Client-generated UUID key to ensure idempotent behavior. Submitting the same key returns the original response without creating a duplicate operation. Keys are scoped to account + region with a 24-hour TTL. + :param patch_configuration_request: The partial configuration update. + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._patch( + idempotency_key=idempotency_key, + patch_configuration_request=patch_configuration_request, + ) + instance = ConfigurationInstance( + self._version, payload, id=self._solution["id"] + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _patch_async( + self, + idempotency_key: Union[str, object] = values.unset, + patch_configuration_request: Union[ + PatchConfigurationRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal async helper for patch operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = patch_configuration_request.to_dict() + + headers = values.of({}) + + if not ( + idempotency_key is values.unset + or (isinstance(idempotency_key, str) and not idempotency_key) + ): + headers["Idempotency-Key"] = idempotency_key + + 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, + idempotency_key: Union[str, object] = values.unset, + patch_configuration_request: Union[ + PatchConfigurationRequest, object + ] = values.unset, + ) -> ConfigurationInstance: + """ + Asynchronous coroutine to patch the ConfigurationInstance + + :param idempotency_key: Client-generated UUID key to ensure idempotent behavior. Submitting the same key returns the original response without creating a duplicate operation. Keys are scoped to account + region with a 24-hour TTL. + :param patch_configuration_request: The partial configuration update. + + :returns: The patched ConfigurationInstance + """ + payload, _, _ = await self._patch_async( + idempotency_key=idempotency_key, + patch_configuration_request=patch_configuration_request, + ) + return ConfigurationInstance(self._version, payload, id=self._solution["id"]) + + async def patch_with_http_info_async( + self, + idempotency_key: Union[str, object] = values.unset, + patch_configuration_request: Union[ + PatchConfigurationRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to patch the ConfigurationInstance and return response metadata + + :param idempotency_key: Client-generated UUID key to ensure idempotent behavior. Submitting the same key returns the original response without creating a duplicate operation. Keys are scoped to account + region with a 24-hour TTL. + :param patch_configuration_request: The partial configuration update. + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._patch_async( + idempotency_key=idempotency_key, + patch_configuration_request=patch_configuration_request, + ) + instance = ConfigurationInstance( + self._version, payload, id=self._solution["id"] + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + def _update( self, idempotency_key: Union[str, object] = values.unset, @@ -707,11 +899,18 @@ class ConversationsV2ChannelSetting(object): def __init__(self, payload: Dict[str, Any]): - self.status_timeouts: Optional[ConversationsV2StatusTimeouts] = payload.get( - "statusTimeouts" + self.status_timeouts: Optional[ConversationsV2StatusTimeouts] = ( + ConversationsV2StatusTimeouts(payload.get("statusTimeouts")) + if payload.get("statusTimeouts") is not None + else None ) self.capture_rules: Optional[List[ConversationsV2CaptureRule]] = ( - payload.get("captureRules") + [ + ConversationsV2CaptureRule(item) if isinstance(item, dict) else item + for item in payload.get("captureRules") + ] + if payload.get("captureRules") is not None + else None ) def to_dict(self): @@ -793,16 +992,45 @@ def __init__(self, payload: Dict[str, Any]): self.display_name: Optional[str] = payload.get("displayName") self.description: Optional[str] = payload.get("description") - self.conversation_grouping_type: Optional["ConfigurationInstance.str"] = ( - payload.get("conversationGroupingType") + self.conversation_grouping_type: Optional[str] = payload.get( + "conversationGroupingType" ) self.memory_store_id: Optional[str] = payload.get("memoryStoreId") self.channel_settings: Optional[ - Dict[str, CreateConfigurationRequestChannelSettingsValue] - ] = payload.get("channelSettings") + Dict[ + str, + ConfigurationList.CreateConfigurationRequestChannelSettingsValue, + ] + ] = ( + { + k: ( + ConfigurationList.CreateConfigurationRequestChannelSettingsValue( + v + ) + if isinstance(v, dict) + else v + ) + for k, v in payload.get("channelSettings").items() + } + if payload.get("channelSettings") is not None + else None + ) self.status_callbacks: Optional[ List[ConfigurationList.CreateConfigurationRequestStatusCallbacks] - ] = payload.get("statusCallbacks") + ] = ( + [ + ( + ConfigurationList.CreateConfigurationRequestStatusCallbacks( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("statusCallbacks") + ] + if payload.get("statusCallbacks") is not None + else None + ) self.intelligence_configuration_ids: Optional[List[str]] = payload.get( "intelligenceConfigurationIds" ) @@ -811,7 +1039,13 @@ def __init__(self, payload: Dict[str, Any]): ) self.conversations_v1_bridge: Optional[ ConfigurationList.CreateConfigurationRequestConversationsV1Bridge - ] = payload.get("conversationsV1Bridge") + ] = ( + ConfigurationList.CreateConfigurationRequestConversationsV1Bridge( + payload.get("conversationsV1Bridge") + ) + if payload.get("conversationsV1Bridge") is not None + else None + ) def to_dict(self): return { @@ -850,11 +1084,32 @@ class CreateConfigurationRequestChannelSettingsValue(object): def __init__(self, payload: Dict[str, Any]): self.status_timeouts: Optional[ - CreateConfigurationRequestChannelSettingsValueStatusTimeouts - ] = payload.get("statusTimeouts") + ConfigurationList.CreateConfigurationRequestChannelSettingsValueStatusTimeouts + ] = ( + ConfigurationList.CreateConfigurationRequestChannelSettingsValueStatusTimeouts( + payload.get("statusTimeouts") + ) + if payload.get("statusTimeouts") is not None + else None + ) self.capture_rules: Optional[ - List[CreateConfigurationRequestChannelSettingsValueCaptureRules] - ] = payload.get("captureRules") + List[ + ConfigurationList.CreateConfigurationRequestChannelSettingsValueCaptureRules + ] + ] = ( + [ + ( + ConfigurationList.CreateConfigurationRequestChannelSettingsValueCaptureRules( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("captureRules") + ] + if payload.get("captureRules") is not None + else None + ) def to_dict(self): return { @@ -930,7 +1185,7 @@ class CreateConfigurationRequestStatusCallbacks(object): def __init__(self, payload: Dict[str, Any]): self.url: Optional[str] = payload.get("url") - self.method: Optional["ConfigurationInstance.str"] = payload.get("method") + self.method: Optional[str] = payload.get("method") def to_dict(self): return { @@ -938,6 +1193,169 @@ def to_dict(self): "method": self.method, } + class PatchConfigurationRequest(object): + """ + :ivar display_name: A human-readable name for the configuration. Limited to 32 characters. + :ivar description: Human-readable description for the configuration. + :ivar conversation_grouping_type: Type of Conversation grouping strategy: - `GROUP_BY_PROFILE`: Groups Communications by resolved Profile from the Memory Store. A Profile is looked up or created for `CUSTOMER` Participant types. All Communications from the same Profile are in the same Conversation, regardless of address or channel. - `GROUP_BY_PARTICIPANT_ADDRESSES`: Groups Communications by Participant addresses across all channels. A customer using +18005550100 will be in the same Conversation whether they contact by SMS, WhatsApp, or RCS. - `GROUP_BY_PARTICIPANT_ADDRESSES_AND_CHANNEL_TYPE`: Groups Communications by both Participant addresses AND channel. A customer using +18005550100 by SMS will be in a different Conversation than the same customer by Voice. + :ivar memory_store_id: The Memory Store ID for profile resolution. + :ivar channel_settings: Channel-specific settings to merge onto the existing channelSettings map. A channel key mapped to a value replaces that channel's settings; a channel key explicitly mapped to null removes it; an omitted channel key is left untouched. + :ivar status_callbacks: + :ivar intelligence_configuration_ids: A list of Conversational Intelligence configuration IDs. + :ivar memory_extraction_enabled: Whether memory extraction is enabled for conversations under this configuration. + :ivar conversations_v1_bridge: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.display_name: Optional[str] = payload.get("displayName") + self.description: Optional[str] = payload.get("description") + self.conversation_grouping_type: Optional[str] = payload.get( + "conversationGroupingType" + ) + self.memory_store_id: Optional[str] = payload.get("memoryStoreId") + self.channel_settings: Optional[ + Dict[ + str, ConfigurationList.PatchConfigurationRequestChannelSettingsValue + ] + ] = ( + { + k: ( + ConfigurationList.PatchConfigurationRequestChannelSettingsValue( + v + ) + if isinstance(v, dict) + else v + ) + for k, v in payload.get("channelSettings").items() + } + if payload.get("channelSettings") is not None + else None + ) + self.status_callbacks: Optional[ + List[ConfigurationList.UpdateConfigurationRequestStatusCallbacks] + ] = ( + [ + ( + ConfigurationList.UpdateConfigurationRequestStatusCallbacks( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("statusCallbacks") + ] + if payload.get("statusCallbacks") is not None + else None + ) + self.intelligence_configuration_ids: Optional[List[str]] = payload.get( + "intelligenceConfigurationIds" + ) + self.memory_extraction_enabled: Optional[bool] = payload.get( + "memoryExtractionEnabled" + ) + self.conversations_v1_bridge: Optional[ + ConfigurationList.PatchConfigurationRequestConversationsV1Bridge + ] = ( + ConfigurationList.PatchConfigurationRequestConversationsV1Bridge( + payload.get("conversationsV1Bridge") + ) + if payload.get("conversationsV1Bridge") is not None + else None + ) + + def to_dict(self): + return { + "displayName": self.display_name, + "description": self.description, + "conversationGroupingType": self.conversation_grouping_type, + "memoryStoreId": self.memory_store_id, + "channelSettings": ( + {k: v.to_dict() for k, v in self.channel_settings.items()} + if self.channel_settings is not None + else None + ), + "statusCallbacks": ( + [ + status_callbacks.to_dict() + for status_callbacks in self.status_callbacks + ] + if self.status_callbacks is not None + else None + ), + "intelligenceConfigurationIds": self.intelligence_configuration_ids, + "memoryExtractionEnabled": self.memory_extraction_enabled, + "conversationsV1Bridge": ( + self.conversations_v1_bridge.to_dict() + if self.conversations_v1_bridge is not None + else None + ), + } + + class PatchConfigurationRequestChannelSettingsValue(object): + """ + :ivar status_timeouts: + :ivar capture_rules: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.status_timeouts: Optional[ + ConfigurationList.UpdateConfigurationRequestChannelSettingsValueStatusTimeouts + ] = ( + ConfigurationList.UpdateConfigurationRequestChannelSettingsValueStatusTimeouts( + payload.get("statusTimeouts") + ) + if payload.get("statusTimeouts") is not None + else None + ) + self.capture_rules: Optional[ + List[ + ConfigurationList.UpdateConfigurationRequestChannelSettingsValueCaptureRules + ] + ] = ( + [ + ( + ConfigurationList.UpdateConfigurationRequestChannelSettingsValueCaptureRules( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("captureRules") + ] + if payload.get("captureRules") is not None + else None + ) + + def to_dict(self): + return { + "statusTimeouts": ( + self.status_timeouts.to_dict() + if self.status_timeouts is not None + else None + ), + "captureRules": ( + [capture_rules.to_dict() for capture_rules in self.capture_rules] + if self.capture_rules is not None + else None + ), + } + + class PatchConfigurationRequestConversationsV1Bridge(object): + """ + :ivar service_id: The Conversations V1 Service SID (IS prefix). One configuration per V1 Service SID. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.service_id: Optional[str] = payload.get("serviceId") + + def to_dict(self): + return { + "serviceId": self.service_id, + } + class UpdateConfigurationRequest(object): """ :ivar display_name: A human-readable name for the configuration. Limited to 32 characters. @@ -955,16 +1373,45 @@ def __init__(self, payload: Dict[str, Any]): self.display_name: Optional[str] = payload.get("displayName") self.description: Optional[str] = payload.get("description") - self.conversation_grouping_type: Optional["ConfigurationInstance.str"] = ( - payload.get("conversationGroupingType") + self.conversation_grouping_type: Optional[str] = payload.get( + "conversationGroupingType" ) self.memory_store_id: Optional[str] = payload.get("memoryStoreId") self.channel_settings: Optional[ - Dict[str, UpdateConfigurationRequestChannelSettingsValue] - ] = payload.get("channelSettings") + Dict[ + str, + ConfigurationList.UpdateConfigurationRequestChannelSettingsValue, + ] + ] = ( + { + k: ( + ConfigurationList.UpdateConfigurationRequestChannelSettingsValue( + v + ) + if isinstance(v, dict) + else v + ) + for k, v in payload.get("channelSettings").items() + } + if payload.get("channelSettings") is not None + else None + ) self.status_callbacks: Optional[ List[ConfigurationList.UpdateConfigurationRequestStatusCallbacks] - ] = payload.get("statusCallbacks") + ] = ( + [ + ( + ConfigurationList.UpdateConfigurationRequestStatusCallbacks( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("statusCallbacks") + ] + if payload.get("statusCallbacks") is not None + else None + ) self.intelligence_configuration_ids: Optional[List[str]] = payload.get( "intelligenceConfigurationIds" ) @@ -973,7 +1420,13 @@ def __init__(self, payload: Dict[str, Any]): ) self.conversations_v1_bridge: Optional[ ConfigurationList.CreateConfigurationRequestConversationsV1Bridge - ] = payload.get("conversationsV1Bridge") + ] = ( + ConfigurationList.CreateConfigurationRequestConversationsV1Bridge( + payload.get("conversationsV1Bridge") + ) + if payload.get("conversationsV1Bridge") is not None + else None + ) def to_dict(self): return { @@ -1012,11 +1465,32 @@ class UpdateConfigurationRequestChannelSettingsValue(object): def __init__(self, payload: Dict[str, Any]): self.status_timeouts: Optional[ - UpdateConfigurationRequestChannelSettingsValueStatusTimeouts - ] = payload.get("statusTimeouts") + ConfigurationList.UpdateConfigurationRequestChannelSettingsValueStatusTimeouts + ] = ( + ConfigurationList.UpdateConfigurationRequestChannelSettingsValueStatusTimeouts( + payload.get("statusTimeouts") + ) + if payload.get("statusTimeouts") is not None + else None + ) self.capture_rules: Optional[ - List[UpdateConfigurationRequestChannelSettingsValueCaptureRules] - ] = payload.get("captureRules") + List[ + ConfigurationList.UpdateConfigurationRequestChannelSettingsValueCaptureRules + ] + ] = ( + [ + ( + ConfigurationList.UpdateConfigurationRequestChannelSettingsValueCaptureRules( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("captureRules") + ] + if payload.get("captureRules") is not None + else None + ) def to_dict(self): return { @@ -1078,7 +1552,7 @@ class UpdateConfigurationRequestStatusCallbacks(object): def __init__(self, payload: Dict[str, Any]): self.url: Optional[str] = payload.get("url") - self.method: Optional["ConfigurationInstance.str"] = payload.get("method") + self.method: Optional[str] = payload.get("method") def to_dict(self): return { diff --git a/twilio/rest/conversations/v2/conversation.py b/twilio/rest/conversations/v2/conversation.py index 43a44569b..e50ec63d1 100644 --- a/twilio/rest/conversations/v2/conversation.py +++ b/twilio/rest/conversations/v2/conversation.py @@ -33,6 +33,7 @@ class ConversationsV2Channel(object): RCS = "RCS" WHATSAPP = "WHATSAPP" CHAT = "CHAT" + VIDEO = "VIDEO" class ConversationsV2ConversationGroupingType(object): GROUP_BY_PROFILE = "GROUP_BY_PROFILE" @@ -68,14 +69,16 @@ class ConversationsV2ParticipantType(object): """ def __init__( - self, version: Version, payload: ResponseResource, id: Optional[str] = None + self, version: Version, payload: Dict[str, Any], id: Optional[str] = None ): super().__init__(version) self.id: Optional[str] = payload.get("id") self.account_id: Optional[str] = payload.get("accountId") self.configuration_id: Optional[str] = payload.get("configurationId") - self.status: Optional["ConversationInstance.str"] = payload.get("status") + self.status: Optional[ + "ConversationInstance.ConversationsV2ConversationStatus" + ] = payload.get("status") self.name: Optional[str] = payload.get("name") self.created_at: Optional[datetime] = deserialize.iso8601_datetime( payload.get("createdAt") @@ -801,7 +804,11 @@ class ConversationsV2Address(object): def __init__(self, payload: Dict[str, Any]): - self.channel: Optional[ConversationsV2Channel] = payload.get("channel") + self.channel: Optional[ConversationsV2Channel] = ( + ConversationsV2Channel(payload.get("channel")) + if payload.get("channel") is not None + else None + ) self.address: Optional[str] = payload.get("address") self.channel_id: Optional[str] = payload.get("channelId") @@ -835,7 +842,7 @@ class ConversationsV2StatusCallbackConfig(object): def __init__(self, payload: Dict[str, Any]): self.url: Optional[str] = payload.get("url") - self.method: Optional["ConversationInstance.str"] = payload.get("method") + self.method: Optional[str] = payload.get("method") def to_dict(self): return { @@ -857,10 +864,29 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.configuration: Optional[ ConversationList.CreateConversationWithConfigRequestConfiguration - ] = payload.get("configuration") + ] = ( + ConversationList.CreateConversationWithConfigRequestConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) self.participants: Optional[ List[ConversationList.CreateConversationWithConfigRequestParticipants] - ] = payload.get("participants") + ] = ( + [ + ( + ConversationList.CreateConversationWithConfigRequestParticipants( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("participants") + ] + if payload.get("participants") is not None + else None + ) def to_dict(self): return { @@ -905,13 +931,26 @@ class CreateConversationWithConfigRequestParticipants(object): def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") - self.type: Optional["ConversationInstance.str"] = payload.get("type") + self.type: Optional[str] = payload.get("type") self.profile_id: Optional[str] = payload.get("profileId") self.addresses: Optional[ List[ ConversationList.CreateConversationWithConfigRequestParticipantsAddresses ] - ] = payload.get("addresses") + ] = ( + [ + ( + ConversationList.CreateConversationWithConfigRequestParticipantsAddresses( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("addresses") + ] + if payload.get("addresses") is not None + else None + ) def to_dict(self): return { @@ -934,7 +973,7 @@ class CreateConversationWithConfigRequestParticipantsAddresses(object): def __init__(self, payload: Dict[str, Any]): - self.channel: Optional["ConversationInstance.str"] = payload.get("channel") + self.channel: Optional[str] = payload.get("channel") self.address: Optional[str] = payload.get("address") self.channel_id: Optional[str] = payload.get("channelId") @@ -955,10 +994,16 @@ class PatchConversationByIdRequest(object): def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") - self.status: Optional["ConversationInstance.str"] = payload.get("status") + self.status: Optional[str] = payload.get("status") self.configuration: Optional[ ConversationList.PatchConversationByIdRequestConfiguration - ] = payload.get("configuration") + ] = ( + ConversationList.PatchConversationByIdRequestConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) def to_dict(self): return { @@ -980,7 +1025,18 @@ def __init__(self, payload: Dict[str, Any]): self.status_callbacks: Optional[ List[ConversationList.ConversationsV2StatusCallbackConfig] - ] = payload.get("statusCallbacks") + ] = ( + [ + ( + ConversationList.ConversationsV2StatusCallbackConfig(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("statusCallbacks") + ] + if payload.get("statusCallbacks") is not None + else None + ) def to_dict(self): return { @@ -1003,7 +1059,7 @@ class UpdateConversationByIdRequest(object): def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") - self.status: Optional["ConversationInstance.str"] = payload.get("status") + self.status: Optional[str] = payload.get("status") def to_dict(self): return { diff --git a/twilio/rest/conversations/v2/operation.py b/twilio/rest/conversations/v2/operation.py index 9eaad7cd4..43dfb3dd3 100644 --- a/twilio/rest/conversations/v2/operation.py +++ b/twilio/rest/conversations/v2/operation.py @@ -47,7 +47,9 @@ def __init__( super().__init__(version) self.operation_id: Optional[str] = payload.get("operationId") - self.status: Optional["OperationInstance.str"] = payload.get("status") + self.status: Optional[ + "OperationInstance.ConversationsV2OperationStatusValue" + ] = payload.get("status") self.created_at: Optional[datetime] = deserialize.iso8601_datetime( payload.get("createdAt") ) diff --git a/twilio/rest/conversations/v2/participant.py b/twilio/rest/conversations/v2/participant.py index 63daceda0..bf82e5337 100644 --- a/twilio/rest/conversations/v2/participant.py +++ b/twilio/rest/conversations/v2/participant.py @@ -33,6 +33,7 @@ class ConversationsV2Channel(object): RCS = "RCS" WHATSAPP = "WHATSAPP" CHAT = "CHAT" + VIDEO = "VIDEO" class ConversationsV2ParticipantType(object): HUMAN_AGENT = "HUMAN_AGENT" @@ -66,7 +67,9 @@ def __init__( self.conversation_id: Optional[str] = payload.get("conversationId") self.account_id: Optional[str] = payload.get("accountId") self.name: Optional[str] = payload.get("name") - self.type: Optional["ParticipantInstance.str"] = payload.get("type") + self.type: Optional["ParticipantInstance.ConversationsV2ParticipantType"] = ( + payload.get("type") + ) self.profile_id: Optional[str] = payload.get("profileId") self.addresses: Optional[List[str]] = payload.get("addresses") self.created_at: Optional[datetime] = deserialize.iso8601_datetime( @@ -515,7 +518,7 @@ class CreateConversationWithConfigRequestParticipantsAddresses(object): def __init__(self, payload: Dict[str, Any]): - self.channel: Optional["ConversationInstance.str"] = payload.get("channel") + self.channel: Optional[str] = payload.get("channel") self.address: Optional[str] = payload.get("address") self.channel_id: Optional[str] = payload.get("channelId") @@ -537,13 +540,26 @@ class CreateParticipantInConversationRequest(object): def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") - self.type: Optional["ParticipantInstance.str"] = payload.get("type") + self.type: Optional[str] = payload.get("type") self.profile_id: Optional[str] = payload.get("profileId") self.addresses: Optional[ List[ ParticipantList.CreateConversationWithConfigRequestParticipantsAddresses ] - ] = payload.get("addresses") + ] = ( + [ + ( + ParticipantList.CreateConversationWithConfigRequestParticipantsAddresses( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("addresses") + ] + if payload.get("addresses") is not None + else None + ) def to_dict(self): return { @@ -568,13 +584,26 @@ class UpdateParticipantInConversationRequest(object): def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") - self.type: Optional["ParticipantInstance.str"] = payload.get("type") + self.type: Optional[str] = payload.get("type") self.profile_id: Optional[str] = payload.get("profileId") self.addresses: Optional[ List[ ParticipantList.CreateConversationWithConfigRequestParticipantsAddresses ] - ] = payload.get("addresses") + ] = ( + [ + ( + ParticipantList.CreateConversationWithConfigRequestParticipantsAddresses( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("addresses") + ] + if payload.get("addresses") is not None + else None + ) def to_dict(self): return { diff --git a/twilio/rest/flex_api/v1/configuration.py b/twilio/rest/flex_api/v1/configuration.py index 6e8f586a0..010d28008 100644 --- a/twilio/rest/flex_api/v1/configuration.py +++ b/twilio/rest/flex_api/v1/configuration.py @@ -102,11 +102,11 @@ def __init__(self, version: Version, payload: Dict[str, Any]): self.taskrouter_target_taskqueue_sid: Optional[str] = payload.get( "taskrouter_target_taskqueue_sid" ) - self.taskrouter_taskqueues: Optional[List[Dict[str, object]]] = payload.get( - "taskrouter_taskqueues" + self.taskrouter_taskqueues: Optional[List[Dict[str, Dict[str, object]]]] = ( + payload.get("taskrouter_taskqueues") ) - self.taskrouter_skills: Optional[List[Dict[str, object]]] = payload.get( - "taskrouter_skills" + self.taskrouter_skills: Optional[List[Dict[str, Dict[str, object]]]] = ( + payload.get("taskrouter_skills") ) self.taskrouter_worker_channels: Optional[Dict[str, object]] = payload.get( "taskrouter_worker_channels" @@ -155,7 +155,7 @@ def __init__(self, version: Version, payload: Dict[str, Any]): self.plugin_service_attributes: Optional[Dict[str, object]] = payload.get( "plugin_service_attributes" ) - self.integrations: Optional[List[Dict[str, object]]] = payload.get( + self.integrations: Optional[List[Dict[str, Dict[str, object]]]] = payload.get( "integrations" ) self.outbound_call_flows: Optional[Dict[str, object]] = payload.get( @@ -177,8 +177,8 @@ def __init__(self, version: Version, payload: Dict[str, Any]): "flex_insights_drilldown" ) self.flex_url: Optional[str] = payload.get("flex_url") - self.channel_configs: Optional[List[Dict[str, object]]] = payload.get( - "channel_configs" + self.channel_configs: Optional[List[Dict[str, Dict[str, object]]]] = ( + payload.get("channel_configs") ) self.debugger_integration: Optional[Dict[str, object]] = payload.get( "debugger_integration" diff --git a/twilio/rest/flex_api/v1/insights_questionnaires.py b/twilio/rest/flex_api/v1/insights_questionnaires.py index 3ecf2f815..315ae6e9e 100644 --- a/twilio/rest/flex_api/v1/insights_questionnaires.py +++ b/twilio/rest/flex_api/v1/insights_questionnaires.py @@ -46,7 +46,9 @@ def __init__( self.name: Optional[str] = payload.get("name") self.description: Optional[str] = payload.get("description") self.active: Optional[bool] = payload.get("active") - self.questions: Optional[List[Dict[str, object]]] = payload.get("questions") + self.questions: Optional[ + List[Dict[str, Dict[str, Dict[str, Dict[str, object]]]]] + ] = payload.get("questions") self.url: Optional[str] = payload.get("url") self._solution = { diff --git a/twilio/rest/iam/v1/o_auth_app.py b/twilio/rest/iam/v1/o_auth_app.py index 14d069bce..67c96df8a 100644 --- a/twilio/rest/iam/v1/o_auth_app.py +++ b/twilio/rest/iam/v1/o_auth_app.py @@ -43,12 +43,18 @@ def __init__(self, payload: Dict[str, Any]): self.owner_sid: Optional[str] = payload.get("owner_sid") self.description: Optional[str] = payload.get("description") self.client_sid: Optional[str] = payload.get("client_sid") - self.token_endpoint_auth_method: Optional["OAuthAppInstance.str"] = ( - payload.get("token_endpoint_auth_method") + self.token_endpoint_auth_method: Optional[str] = payload.get( + "token_endpoint_auth_method" ) self.policy: Optional[ OAuthAppList.IamV1OrganizationVendoroauthappPolicy - ] = payload.get("policy") + ] = ( + OAuthAppList.IamV1OrganizationVendoroauthappPolicy( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") def to_dict(self): @@ -79,7 +85,13 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.policy: Optional[ OAuthAppList.IamV1OrganizationVendorOauthAppUpdateRequestPolicy - ] = payload.get("policy") + ] = ( + OAuthAppList.IamV1OrganizationVendorOauthAppUpdateRequestPolicy( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") def to_dict(self): @@ -314,12 +326,18 @@ def __init__(self, payload: Dict[str, Any]): self.owner_sid: Optional[str] = payload.get("owner_sid") self.description: Optional[str] = payload.get("description") self.client_sid: Optional[str] = payload.get("client_sid") - self.token_endpoint_auth_method: Optional["OAuthAppInstance.str"] = ( - payload.get("token_endpoint_auth_method") + self.token_endpoint_auth_method: Optional[str] = payload.get( + "token_endpoint_auth_method" ) self.policy: Optional[ OAuthAppList.IamV1OrganizationVendoroauthappPolicy - ] = payload.get("policy") + ] = ( + OAuthAppList.IamV1OrganizationVendoroauthappPolicy( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") def to_dict(self): @@ -350,7 +368,13 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.policy: Optional[ OAuthAppList.IamV1OrganizationVendorOauthAppUpdateRequestPolicy - ] = payload.get("policy") + ] = ( + OAuthAppList.IamV1OrganizationVendorOauthAppUpdateRequestPolicy( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") def to_dict(self): @@ -624,12 +648,18 @@ def __init__(self, payload: Dict[str, Any]): self.owner_sid: Optional[str] = payload.get("owner_sid") self.description: Optional[str] = payload.get("description") self.client_sid: Optional[str] = payload.get("client_sid") - self.token_endpoint_auth_method: Optional["OAuthAppInstance.str"] = ( - payload.get("token_endpoint_auth_method") + self.token_endpoint_auth_method: Optional[str] = payload.get( + "token_endpoint_auth_method" ) self.policy: Optional[ OAuthAppList.IamV1OrganizationVendoroauthappPolicy - ] = payload.get("policy") + ] = ( + OAuthAppList.IamV1OrganizationVendoroauthappPolicy( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") def to_dict(self): @@ -660,7 +690,13 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.policy: Optional[ OAuthAppList.IamV1OrganizationVendorOauthAppUpdateRequestPolicy - ] = payload.get("policy") + ] = ( + OAuthAppList.IamV1OrganizationVendorOauthAppUpdateRequestPolicy( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") def to_dict(self): diff --git a/twilio/rest/insights/v2/__init__.py b/twilio/rest/insights/v2/__init__.py index 9f2e26d1f..5ebe7481d 100644 --- a/twilio/rest/insights/v2/__init__.py +++ b/twilio/rest/insights/v2/__init__.py @@ -16,7 +16,9 @@ from twilio.base.version import Version from twilio.base.domain import Domain from twilio.rest.insights.v2.inbound import InboundList +from twilio.rest.insights.v2.inbound_report import InboundReportList from twilio.rest.insights.v2.outbound import OutboundList +from twilio.rest.insights.v2.outbound_report import OutboundReportList from twilio.rest.insights.v2.report import ReportList @@ -29,6 +31,8 @@ def __init__(self, domain: Domain): :param domain: The Twilio.insights domain """ super().__init__(domain, "v2") + self._inbound_reports: Optional[InboundReportList] = None + self._outbound_reports: Optional[OutboundReportList] = None self._reports: Optional[ReportList] = None def inbound(self, report_id: str, inbound_id: str = None): @@ -45,6 +49,12 @@ def inbound(self, report_id: str, inbound_id: str = None): return list_instance(inbound_id) return list_instance + @property + def inbound_reports(self) -> InboundReportList: + if self._inbound_reports is None: + self._inbound_reports = InboundReportList(self) + return self._inbound_reports + def outbound(self, report_id: str, outbound_id: str = None): """ Access the OutboundList resource @@ -59,6 +69,12 @@ def outbound(self, report_id: str, outbound_id: str = None): return list_instance(outbound_id) return list_instance + @property + def outbound_reports(self) -> OutboundReportList: + if self._outbound_reports is None: + self._outbound_reports = OutboundReportList(self) + return self._outbound_reports + @property def reports(self) -> ReportList: if self._reports is None: diff --git a/twilio/rest/insights/v2/inbound.py b/twilio/rest/insights/v2/inbound.py index 47bf2a026..b46c4e9d2 100644 --- a/twilio/rest/insights/v2/inbound.py +++ b/twilio/rest/insights/v2/inbound.py @@ -12,11 +12,10 @@ Do not edit the class manually. """ -from datetime import datetime 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 @@ -24,103 +23,11 @@ class InboundInstance(InstanceResource): - - class InsightsV2CreatePhoneNumbersReportRequest(object): - """ - :ivar time_range: - :ivar filters: - :ivar size: The number of max available top Phone Numbers to generate. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.time_range: Optional[ - InboundList.InsightsV2CreatePhoneNumbersReportRequestTimeRange - ] = payload.get("time_range") - self.filters: Optional[List[InboundList.PhoneNumberReportFilter]] = ( - payload.get("filters") - ) - self.size: Optional[int] = payload.get("size") - - def to_dict(self): - return { - "time_range": ( - self.time_range.to_dict() if self.time_range is not None else None - ), - "filters": ( - [filters.to_dict() for filters in self.filters] - if self.filters is not None - else None - ), - "size": self.size, - } - - class InsightsV2CreatePhoneNumbersReportRequestTimeRange(object): - """ - :ivar start_datetime: Start date time of the report - :ivar end_datetime: End date time of the report - """ - - def __init__(self, payload: Dict[str, Any]): - - self.start_datetime: Optional[datetime] = payload.get("start_datetime") - self.end_datetime: Optional[datetime] = payload.get("end_datetime") - - def to_dict(self): - return { - "start_datetime": self.start_datetime, - "end_datetime": self.end_datetime, - } - - class PhoneNumberReportFilter(object): - """ - :ivar key: The name of the filter - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - - class ReportFilter(object): - """ - :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent' - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - - class ReportStatus(object): - CREATED = "created" - RUNNING = "running" - COMPLETED = "completed" - """ - :ivar account_sid: The unique SID identifier of the Account. - :ivar report_id: The report identifier as Voice Insights Report TTID. - :ivar status: - :ivar request_meta: - :ivar url: The URL of this resource. :ivar handle: Inbound phone number handle represented in the report. :ivar total_calls: Total number of calls made with the given handle during the report period. - :ivar call_answer_score: The call answer score measures customers behavior to the delivered calls. The score is a value between 0 and 100, where 100 indicates that all calls were successfully answered. - :ivar call_state_percentage: + :ivar call_answer_score: The call answer score measures customers behavior to the delivered calls. The score is a value between 0 and 100, where 100 indicates that all calls were successfully answered. + :ivar call_state_percentage: :ivar silent_calls_percentage: Percentage of inbound calls with silence tags over total outbound calls. A silent tag is indicative of a connectivity issue or muted audio. """ @@ -129,11 +36,6 @@ def __init__( ): super().__init__(version) - self.account_sid: Optional[str] = payload.get("account_sid") - self.report_id: Optional[str] = payload.get("report_id") - self.status: Optional["InboundInstance.str"] = payload.get("status") - self.request_meta: Optional[str] = payload.get("request_meta") - self.url: Optional[str] = payload.get("url") self.handle: Optional[str] = payload.get("handle") self.total_calls: Optional[int] = deserialize.integer( payload.get("total_calls") @@ -148,91 +50,6 @@ def __init__( "report_id": report_id or self.report_id, } - self._context: Optional[InboundContext] = None - - @property - def _proxy(self) -> "InboundContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: InboundContext for this InboundInstance - """ - if self._context is None: - self._context = InboundContext( - self._version, - report_id=self._solution["report_id"], - ) - return self._context - - def create( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> "InboundInstance": - """ - Create the InboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created InboundInstance - """ - return self._proxy.create( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request, - ) - - async def create_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> "InboundInstance": - """ - Asynchronous coroutine to create the InboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created InboundInstance - """ - return await self._proxy.create_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request, - ) - - def create_with_http_info( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Create the InboundInstance with HTTP info - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - return self._proxy.create_with_http_info( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request, - ) - - async def create_with_http_info_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronous coroutine to create the InboundInstance with HTTP info - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - return await self._proxy.create_with_http_info_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request, - ) - def __repr__(self) -> str: """ Provide a friendly representation @@ -243,244 +60,6 @@ def __repr__(self) -> str: return "".format(context) -class InboundContext(InstanceContext): - - class InsightsV2CreatePhoneNumbersReportRequest(object): - """ - :ivar time_range: - :ivar filters: - :ivar size: The number of max available top Phone Numbers to generate. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.time_range: Optional[ - InboundList.InsightsV2CreatePhoneNumbersReportRequestTimeRange - ] = payload.get("time_range") - self.filters: Optional[List[InboundList.PhoneNumberReportFilter]] = ( - payload.get("filters") - ) - self.size: Optional[int] = payload.get("size") - - def to_dict(self): - return { - "time_range": ( - self.time_range.to_dict() if self.time_range is not None else None - ), - "filters": ( - [filters.to_dict() for filters in self.filters] - if self.filters is not None - else None - ), - "size": self.size, - } - - class InsightsV2CreatePhoneNumbersReportRequestTimeRange(object): - """ - :ivar start_datetime: Start date time of the report - :ivar end_datetime: End date time of the report - """ - - def __init__(self, payload: Dict[str, Any]): - - self.start_datetime: Optional[datetime] = payload.get("start_datetime") - self.end_datetime: Optional[datetime] = payload.get("end_datetime") - - def to_dict(self): - return { - "start_datetime": self.start_datetime, - "end_datetime": self.end_datetime, - } - - class PhoneNumberReportFilter(object): - """ - :ivar key: The name of the filter - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - - class ReportFilter(object): - """ - :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent' - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - - def __init__(self, version: Version, report_id: str): - """ - Initialize the InboundContext - - :param version: Version that contains the resource - :param report_id: A unique Report Id. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "report_id": report_id, - } - self._uri = "/Voice/Reports/PhoneNumbers/Inbound".format(**self._solution) - - def _create( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_v2_create_phone_numbers_report_request.to_dict() - - headers = values.of({}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return self._version.create_with_response_info( - method="POST", uri=self._uri, data=data, headers=headers - ) - - def create( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> InboundInstance: - """ - Create the InboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created InboundInstance - """ - payload, _, _ = self._create( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - return InboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - - def create_with_http_info( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Create the InboundInstance and return response metadata - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - instance = InboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _create_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal async helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_v2_create_phone_numbers_report_request.to_dict() - - headers = values.of({}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - async def create_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> InboundInstance: - """ - Asynchronous coroutine to create the InboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created InboundInstance - """ - payload, _, _ = await self._create_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - return InboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - - async def create_with_http_info_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronous coroutine to create the InboundInstance and return response metadata - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - instance = InboundInstance( - self._version, payload, report_id=self._solution["report_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 InboundPage(Page): def get_instance(self, payload: Dict[str, Any]) -> InboundInstance: @@ -505,87 +84,6 @@ def __repr__(self) -> str: class InboundList(ListResource): - class InsightsV2CreatePhoneNumbersReportRequest(object): - """ - :ivar time_range: - :ivar filters: - :ivar size: The number of max available top Phone Numbers to generate. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.time_range: Optional[ - InboundList.InsightsV2CreatePhoneNumbersReportRequestTimeRange - ] = payload.get("time_range") - self.filters: Optional[List[InboundList.PhoneNumberReportFilter]] = ( - payload.get("filters") - ) - self.size: Optional[int] = payload.get("size") - - def to_dict(self): - return { - "time_range": ( - self.time_range.to_dict() if self.time_range is not None else None - ), - "filters": ( - [filters.to_dict() for filters in self.filters] - if self.filters is not None - else None - ), - "size": self.size, - } - - class InsightsV2CreatePhoneNumbersReportRequestTimeRange(object): - """ - :ivar start_datetime: Start date time of the report - :ivar end_datetime: End date time of the report - """ - - def __init__(self, payload: Dict[str, Any]): - - self.start_datetime: Optional[datetime] = payload.get("start_datetime") - self.end_datetime: Optional[datetime] = payload.get("end_datetime") - - def to_dict(self): - return { - "start_datetime": self.start_datetime, - "end_datetime": self.end_datetime, - } - - class PhoneNumberReportFilter(object): - """ - :ivar key: The name of the filter - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - - class ReportFilter(object): - """ - :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent' - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - def __init__(self, version: Version, report_id: str): """ Initialize the InboundList @@ -604,136 +102,6 @@ def __init__(self, version: Version, report_id: str): **self._solution ) - def _create( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_v2_create_phone_numbers_report_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, data=data, headers=headers - ) - - def create( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> InboundInstance: - """ - Create the InboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created InboundInstance - """ - payload, _, _ = self._create( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - return InboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - - def create_with_http_info( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Create the InboundInstance and return response metadata - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - instance = InboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _create_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal async helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_v2_create_phone_numbers_report_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, data=data, headers=headers - ) - - async def create_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> InboundInstance: - """ - Asynchronously create the InboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created InboundInstance - """ - payload, _, _ = await self._create_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - return InboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - - async def create_with_http_info_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronously create the InboundInstance and return response metadata - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - instance = InboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - def stream( self, limit: Optional[int] = None, @@ -1099,22 +467,6 @@ async def get_page_async(self, target_url: str) -> InboundPage: response = await self._version.domain.twilio.request_async("GET", target_url) return InboundPage(self._version, response, solution=self._solution) - def get(self, report_id: str) -> InboundContext: - """ - Constructs a InboundContext - - :param report_id: A unique Report Id. - """ - return InboundContext(self._version, report_id=report_id) - - def __call__(self, report_id: str) -> InboundContext: - """ - Constructs a InboundContext - - :param report_id: A unique Report Id. - """ - return InboundContext(self._version, report_id=report_id) - def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/insights/v2/inbound_report.py b/twilio/rest/insights/v2/inbound_report.py new file mode 100644 index 000000000..18f45a0dd --- /dev/null +++ b/twilio/rest/insights/v2/inbound_report.py @@ -0,0 +1,394 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Sample/reference Twilio API. + This is the reference API for the rest-proxy server. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, List, Optional, Union +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 InboundReportInstance(InstanceResource): + + class InsightsV2CreatePhoneNumbersReportRequest(object): + """ + :ivar time_range: + :ivar filters: + :ivar size: The number of max available top Phone Numbers to generate. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.time_range: Optional[ + InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange + ] = ( + InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange( + payload.get("time_range") + ) + if payload.get("time_range") is not None + else None + ) + self.filters: Optional[List[InboundReportList.PhoneNumberReportFilter]] = ( + [ + ( + InboundReportList.PhoneNumberReportFilter(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("filters") + ] + if payload.get("filters") is not None + else None + ) + self.size: Optional[int] = payload.get("size") + + def to_dict(self): + return { + "time_range": ( + self.time_range.to_dict() if self.time_range is not None else None + ), + "filters": ( + [filters.to_dict() for filters in self.filters] + if self.filters is not None + else None + ), + "size": self.size, + } + + class InsightsV2CreatePhoneNumbersReportRequestTimeRange(object): + """ + :ivar start_datetime: Start date time of the report + :ivar end_datetime: End date time of the report + """ + + def __init__(self, payload: Dict[str, Any]): + + self.start_datetime: Optional[datetime] = payload.get("start_datetime") + self.end_datetime: Optional[datetime] = payload.get("end_datetime") + + def to_dict(self): + return { + "start_datetime": self.start_datetime, + "end_datetime": self.end_datetime, + } + + class PhoneNumberReportFilter(object): + """ + :ivar key: The name of the filter + :ivar values: List of supported filter values for the field name + """ + + def __init__(self, payload: Dict[str, Any]): + + self.key: Optional[str] = payload.get("key") + self.values: Optional[List[str]] = payload.get("values") + + def to_dict(self): + return { + "key": self.key, + "values": self.values, + } + + class ReportFilter(object): + """ + :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent' + :ivar values: List of supported filter values for the field name + """ + + def __init__(self, payload: Dict[str, Any]): + + self.key: Optional[str] = payload.get("key") + self.values: Optional[List[str]] = payload.get("values") + + def to_dict(self): + return { + "key": self.key, + "values": self.values, + } + + class ReportStatus(object): + CREATED = "created" + RUNNING = "running" + COMPLETED = "completed" + + """ + :ivar account_sid: The unique SID identifier of the Account. + :ivar report_id: The report identifier as Voice Insights Report TTID. + :ivar status: + :ivar request_meta: + :ivar url: The URL of this resource. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.report_id: Optional[str] = payload.get("report_id") + self.status: Optional["InboundReportInstance.ReportStatus"] = payload.get( + "status" + ) + self.request_meta: Optional[str] = payload.get("request_meta") + self.url: Optional[str] = payload.get("url") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class InboundReportList(ListResource): + + class InsightsV2CreatePhoneNumbersReportRequest(object): + """ + :ivar time_range: + :ivar filters: + :ivar size: The number of max available top Phone Numbers to generate. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.time_range: Optional[ + InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange + ] = ( + InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange( + payload.get("time_range") + ) + if payload.get("time_range") is not None + else None + ) + self.filters: Optional[List[InboundReportList.PhoneNumberReportFilter]] = ( + [ + ( + InboundReportList.PhoneNumberReportFilter(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("filters") + ] + if payload.get("filters") is not None + else None + ) + self.size: Optional[int] = payload.get("size") + + def to_dict(self): + return { + "time_range": ( + self.time_range.to_dict() if self.time_range is not None else None + ), + "filters": ( + [filters.to_dict() for filters in self.filters] + if self.filters is not None + else None + ), + "size": self.size, + } + + class InsightsV2CreatePhoneNumbersReportRequestTimeRange(object): + """ + :ivar start_datetime: Start date time of the report + :ivar end_datetime: End date time of the report + """ + + def __init__(self, payload: Dict[str, Any]): + + self.start_datetime: Optional[datetime] = payload.get("start_datetime") + self.end_datetime: Optional[datetime] = payload.get("end_datetime") + + def to_dict(self): + return { + "start_datetime": self.start_datetime, + "end_datetime": self.end_datetime, + } + + class PhoneNumberReportFilter(object): + """ + :ivar key: The name of the filter + :ivar values: List of supported filter values for the field name + """ + + def __init__(self, payload: Dict[str, Any]): + + self.key: Optional[str] = payload.get("key") + self.values: Optional[List[str]] = payload.get("values") + + def to_dict(self): + return { + "key": self.key, + "values": self.values, + } + + class ReportFilter(object): + """ + :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent' + :ivar values: List of supported filter values for the field name + """ + + def __init__(self, payload: Dict[str, Any]): + + self.key: Optional[str] = payload.get("key") + self.values: Optional[List[str]] = payload.get("values") + + def to_dict(self): + return { + "key": self.key, + "values": self.values, + } + + def __init__(self, version: Version): + """ + Initialize the InboundReportList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Voice/Reports/PhoneNumbers/Inbound" + + def _create( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = insights_v2_create_phone_numbers_report_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, data=data, headers=headers + ) + + def create( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> InboundReportInstance: + """ + Create the InboundReportInstance + + :param insights_v2_create_phone_numbers_report_request: + + :returns: The created InboundReportInstance + """ + payload, _, _ = self._create( + insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request + ) + return InboundReportInstance(self._version, payload) + + def create_with_http_info( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Create the InboundReportInstance and return response metadata + + :param insights_v2_create_phone_numbers_report_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create( + insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request + ) + instance = InboundReportInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = insights_v2_create_phone_numbers_report_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, data=data, headers=headers + ) + + async def create_async( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> InboundReportInstance: + """ + Asynchronously create the InboundReportInstance + + :param insights_v2_create_phone_numbers_report_request: + + :returns: The created InboundReportInstance + """ + payload, _, _ = await self._create_async( + insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request + ) + return InboundReportInstance(self._version, payload) + + async def create_with_http_info_async( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronously create the InboundReportInstance and return response metadata + + :param insights_v2_create_phone_numbers_report_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async( + insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request + ) + instance = InboundReportInstance(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/insights/v2/outbound.py b/twilio/rest/insights/v2/outbound.py index 2774a09d0..e880b1f23 100644 --- a/twilio/rest/insights/v2/outbound.py +++ b/twilio/rest/insights/v2/outbound.py @@ -12,11 +12,10 @@ Do not edit the class manually. """ -from datetime import datetime 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 @@ -24,136 +23,19 @@ class OutboundInstance(InstanceResource): - - class CountyCarrierValueCarriers(object): - """ - :ivar carrier: The name of the carrier. - :ivar total_calls: Total number of outbound calls for the carrier in the country. - :ivar blocked_calls: Total number of blocked outbound calls for the carrier in the country. - :ivar blocked_calls_percentage: Percentage of blocked outbound calls for the carrier in the country. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.carrier: Optional[str] = payload.get("carrier") - self.total_calls: Optional[int] = payload.get("total_calls") - self.blocked_calls: Optional[int] = payload.get("blocked_calls") - self.blocked_calls_percentage: Optional[float] = payload.get( - "blocked_calls_percentage" - ) - - def to_dict(self): - return { - "carrier": self.carrier, - "total_calls": self.total_calls, - "blocked_calls": self.blocked_calls, - "blocked_calls_percentage": self.blocked_calls_percentage, - } - - class InsightsV2CreatePhoneNumbersReportRequest(object): - """ - :ivar time_range: - :ivar filters: - :ivar size: The number of max available top Phone Numbers to generate. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.time_range: Optional[ - InboundList.InsightsV2CreatePhoneNumbersReportRequestTimeRange - ] = payload.get("time_range") - self.filters: Optional[List[InboundList.PhoneNumberReportFilter]] = ( - payload.get("filters") - ) - self.size: Optional[int] = payload.get("size") - - def to_dict(self): - return { - "time_range": ( - self.time_range.to_dict() if self.time_range is not None else None - ), - "filters": ( - [filters.to_dict() for filters in self.filters] - if self.filters is not None - else None - ), - "size": self.size, - } - - class InsightsV2CreatePhoneNumbersReportRequestTimeRange(object): - """ - :ivar start_datetime: Start date time of the report - :ivar end_datetime: End date time of the report - """ - - def __init__(self, payload: Dict[str, Any]): - - self.start_datetime: Optional[datetime] = payload.get("start_datetime") - self.end_datetime: Optional[datetime] = payload.get("end_datetime") - - def to_dict(self): - return { - "start_datetime": self.start_datetime, - "end_datetime": self.end_datetime, - } - - class PhoneNumberReportFilter(object): - """ - :ivar key: The name of the filter - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - - class ReportFilter(object): - """ - :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent' - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - - class ReportStatus(object): - CREATED = "created" - RUNNING = "running" - COMPLETED = "completed" - """ - :ivar account_sid: The unique SID identifier of the Account. - :ivar report_id: The report identifier as Voice Insights Report TTID. - :ivar status: - :ivar request_meta: - :ivar url: The URL of this resource. - :ivar handle: Inbound phone number handle represented in the report. - :ivar total_calls: Total number of calls made with the given handle during the report period. - :ivar call_answer_score: The call answer score measures customers behavior to the delivered calls. The score is a value between 0 and 100, where 100 indicates that all calls were successfully answered. - :ivar call_state_percentage: - :ivar silent_calls_percentage: Percentage of inbound calls with silence tags over total outbound calls. A silent tag is indicative of a connectivity issue or muted audio. - :ivar calls_by_device_type: Number of calls made with each device type. `voip`, `mobile`, `landline`, `unknown` - :ivar answer_rate_device_type: Answer rate for each device type. `voip`, `mobile`, `landline`, `unknown` + :ivar handle: The outbound phone number handle. + :ivar total_calls: Total number of outbound calls made with the given handle during the report period. + :ivar call_answer_score: The call answer score measures customers behavior to the delivered calls. The score is a value between 0 and 100, where 100 indicates that all calls were successfully answered. + :ivar calls_by_device_type: Number of calls made with each device type. `voip`, `mobile`, `landline`, `unknown` + :ivar answer_rate_device_type: Answer rate for each device type. `voip`, `mobile`, `landline`, `unknown` + :ivar call_state_percentage: :ivar blocked_calls_by_carrier: Percentage of blocked calls by carrier per country. + :ivar silent_calls_percentage: Percentage of calls with silence tags over total calls. A silent tag is indicative of a connectivity issue or muted audio. :ivar short_duration_calls_percentage: Percentage of completed outbound calls under 10 seconds (PSTN Short call tags); More than 15% is typically low trust measured. :ivar long_duration_calls_percentage: Percentage of long duration calls ( >= 60 seconds) :ivar potential_robocalls_percentage: Percentage of completed outbound calls to unassigned or unallocated phone numbers. - :ivar answering_machine_detection: + :ivar answering_machine_detection: """ def __init__( @@ -161,29 +43,24 @@ def __init__( ): super().__init__(version) - self.account_sid: Optional[str] = payload.get("account_sid") - self.report_id: Optional[str] = payload.get("report_id") - self.status: Optional["InboundInstance.str"] = payload.get("status") - self.request_meta: Optional[str] = payload.get("request_meta") - self.url: Optional[str] = payload.get("url") self.handle: Optional[str] = payload.get("handle") self.total_calls: Optional[int] = deserialize.integer( payload.get("total_calls") ) self.call_answer_score: Optional[float] = payload.get("call_answer_score") - self.call_state_percentage: Optional[str] = payload.get("call_state_percentage") - self.silent_calls_percentage: Optional[float] = payload.get( - "silent_calls_percentage" - ) self.calls_by_device_type: Optional[Dict[str, int]] = payload.get( "calls_by_device_type" ) self.answer_rate_device_type: Optional[Dict[str, float]] = payload.get( "answer_rate_device_type" ) + self.call_state_percentage: Optional[str] = payload.get("call_state_percentage") self.blocked_calls_by_carrier: Optional[List[str]] = payload.get( "blocked_calls_by_carrier" ) + self.silent_calls_percentage: Optional[float] = payload.get( + "silent_calls_percentage" + ) self.short_duration_calls_percentage: Optional[float] = payload.get( "short_duration_calls_percentage" ) @@ -201,91 +78,6 @@ def __init__( "report_id": report_id or self.report_id, } - self._context: Optional[OutboundContext] = None - - @property - def _proxy(self) -> "OutboundContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: OutboundContext for this OutboundInstance - """ - if self._context is None: - self._context = OutboundContext( - self._version, - report_id=self._solution["report_id"], - ) - return self._context - - def create( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> "OutboundInstance": - """ - Create the OutboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created OutboundInstance - """ - return self._proxy.create( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request, - ) - - async def create_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> "OutboundInstance": - """ - Asynchronous coroutine to create the OutboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created OutboundInstance - """ - return await self._proxy.create_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request, - ) - - def create_with_http_info( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Create the OutboundInstance with HTTP info - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - return self._proxy.create_with_http_info( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request, - ) - - async def create_with_http_info_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronous coroutine to create the OutboundInstance with HTTP info - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - return await self._proxy.create_with_http_info_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request, - ) - def __repr__(self) -> str: """ Provide a friendly representation @@ -296,269 +88,6 @@ def __repr__(self) -> str: return "".format(context) -class OutboundContext(InstanceContext): - - class CountyCarrierValueCarriers(object): - """ - :ivar carrier: The name of the carrier. - :ivar total_calls: Total number of outbound calls for the carrier in the country. - :ivar blocked_calls: Total number of blocked outbound calls for the carrier in the country. - :ivar blocked_calls_percentage: Percentage of blocked outbound calls for the carrier in the country. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.carrier: Optional[str] = payload.get("carrier") - self.total_calls: Optional[int] = payload.get("total_calls") - self.blocked_calls: Optional[int] = payload.get("blocked_calls") - self.blocked_calls_percentage: Optional[float] = payload.get( - "blocked_calls_percentage" - ) - - def to_dict(self): - return { - "carrier": self.carrier, - "total_calls": self.total_calls, - "blocked_calls": self.blocked_calls, - "blocked_calls_percentage": self.blocked_calls_percentage, - } - - class InsightsV2CreatePhoneNumbersReportRequest(object): - """ - :ivar time_range: - :ivar filters: - :ivar size: The number of max available top Phone Numbers to generate. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.time_range: Optional[ - InboundList.InsightsV2CreatePhoneNumbersReportRequestTimeRange - ] = payload.get("time_range") - self.filters: Optional[List[InboundList.PhoneNumberReportFilter]] = ( - payload.get("filters") - ) - self.size: Optional[int] = payload.get("size") - - def to_dict(self): - return { - "time_range": ( - self.time_range.to_dict() if self.time_range is not None else None - ), - "filters": ( - [filters.to_dict() for filters in self.filters] - if self.filters is not None - else None - ), - "size": self.size, - } - - class InsightsV2CreatePhoneNumbersReportRequestTimeRange(object): - """ - :ivar start_datetime: Start date time of the report - :ivar end_datetime: End date time of the report - """ - - def __init__(self, payload: Dict[str, Any]): - - self.start_datetime: Optional[datetime] = payload.get("start_datetime") - self.end_datetime: Optional[datetime] = payload.get("end_datetime") - - def to_dict(self): - return { - "start_datetime": self.start_datetime, - "end_datetime": self.end_datetime, - } - - class PhoneNumberReportFilter(object): - """ - :ivar key: The name of the filter - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - - class ReportFilter(object): - """ - :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent' - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - - def __init__(self, version: Version, report_id: str): - """ - Initialize the OutboundContext - - :param version: Version that contains the resource - :param report_id: A unique Report Id. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "report_id": report_id, - } - self._uri = "/Voice/Reports/PhoneNumbers/Outbound".format(**self._solution) - - def _create( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_v2_create_phone_numbers_report_request.to_dict() - - headers = values.of({}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return self._version.create_with_response_info( - method="POST", uri=self._uri, data=data, headers=headers - ) - - def create( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> OutboundInstance: - """ - Create the OutboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created OutboundInstance - """ - payload, _, _ = self._create( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - return OutboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - - def create_with_http_info( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Create the OutboundInstance and return response metadata - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - instance = OutboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _create_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal async helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_v2_create_phone_numbers_report_request.to_dict() - - headers = values.of({}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - async def create_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> OutboundInstance: - """ - Asynchronous coroutine to create the OutboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created OutboundInstance - """ - payload, _, _ = await self._create_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - return OutboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - - async def create_with_http_info_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronous coroutine to create the OutboundInstance and return response metadata - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - instance = OutboundInstance( - self._version, payload, report_id=self._solution["report_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 OutboundPage(Page): def get_instance(self, payload: Dict[str, Any]) -> OutboundInstance: @@ -583,112 +112,6 @@ def __repr__(self) -> str: class OutboundList(ListResource): - class CountyCarrierValueCarriers(object): - """ - :ivar carrier: The name of the carrier. - :ivar total_calls: Total number of outbound calls for the carrier in the country. - :ivar blocked_calls: Total number of blocked outbound calls for the carrier in the country. - :ivar blocked_calls_percentage: Percentage of blocked outbound calls for the carrier in the country. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.carrier: Optional[str] = payload.get("carrier") - self.total_calls: Optional[int] = payload.get("total_calls") - self.blocked_calls: Optional[int] = payload.get("blocked_calls") - self.blocked_calls_percentage: Optional[float] = payload.get( - "blocked_calls_percentage" - ) - - def to_dict(self): - return { - "carrier": self.carrier, - "total_calls": self.total_calls, - "blocked_calls": self.blocked_calls, - "blocked_calls_percentage": self.blocked_calls_percentage, - } - - class InsightsV2CreatePhoneNumbersReportRequest(object): - """ - :ivar time_range: - :ivar filters: - :ivar size: The number of max available top Phone Numbers to generate. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.time_range: Optional[ - InboundList.InsightsV2CreatePhoneNumbersReportRequestTimeRange - ] = payload.get("time_range") - self.filters: Optional[List[InboundList.PhoneNumberReportFilter]] = ( - payload.get("filters") - ) - self.size: Optional[int] = payload.get("size") - - def to_dict(self): - return { - "time_range": ( - self.time_range.to_dict() if self.time_range is not None else None - ), - "filters": ( - [filters.to_dict() for filters in self.filters] - if self.filters is not None - else None - ), - "size": self.size, - } - - class InsightsV2CreatePhoneNumbersReportRequestTimeRange(object): - """ - :ivar start_datetime: Start date time of the report - :ivar end_datetime: End date time of the report - """ - - def __init__(self, payload: Dict[str, Any]): - - self.start_datetime: Optional[datetime] = payload.get("start_datetime") - self.end_datetime: Optional[datetime] = payload.get("end_datetime") - - def to_dict(self): - return { - "start_datetime": self.start_datetime, - "end_datetime": self.end_datetime, - } - - class PhoneNumberReportFilter(object): - """ - :ivar key: The name of the filter - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - - class ReportFilter(object): - """ - :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent' - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - def __init__(self, version: Version, report_id: str): """ Initialize the OutboundList @@ -707,136 +130,6 @@ def __init__(self, version: Version, report_id: str): **self._solution ) - def _create( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_v2_create_phone_numbers_report_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, data=data, headers=headers - ) - - def create( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> OutboundInstance: - """ - Create the OutboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created OutboundInstance - """ - payload, _, _ = self._create( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - return OutboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - - def create_with_http_info( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Create the OutboundInstance and return response metadata - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - instance = OutboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _create_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal async helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_v2_create_phone_numbers_report_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, data=data, headers=headers - ) - - async def create_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> OutboundInstance: - """ - Asynchronously create the OutboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created OutboundInstance - """ - payload, _, _ = await self._create_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - return OutboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - - async def create_with_http_info_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronously create the OutboundInstance and return response metadata - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - instance = OutboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - def stream( self, limit: Optional[int] = None, @@ -1202,22 +495,6 @@ async def get_page_async(self, target_url: str) -> OutboundPage: response = await self._version.domain.twilio.request_async("GET", target_url) return OutboundPage(self._version, response, solution=self._solution) - def get(self, report_id: str) -> OutboundContext: - """ - Constructs a OutboundContext - - :param report_id: A unique Report Id. - """ - return OutboundContext(self._version, report_id=report_id) - - def __call__(self, report_id: str) -> OutboundContext: - """ - Constructs a OutboundContext - - :param report_id: A unique Report Id. - """ - return OutboundContext(self._version, report_id=report_id) - def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/insights/v2/outbound_report.py b/twilio/rest/insights/v2/outbound_report.py new file mode 100644 index 000000000..c79d3b6f7 --- /dev/null +++ b/twilio/rest/insights/v2/outbound_report.py @@ -0,0 +1,325 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Sample/reference Twilio API. + This is the reference API for the rest-proxy server. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, List, Optional, Union +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 OutboundReportInstance(InstanceResource): + + class InsightsV2CreatePhoneNumbersReportRequest(object): + """ + :ivar time_range: + :ivar filters: + :ivar size: The number of max available top Phone Numbers to generate. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.time_range: Optional[ + InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange + ] = ( + InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange( + payload.get("time_range") + ) + if payload.get("time_range") is not None + else None + ) + self.filters: Optional[List[InboundReportList.PhoneNumberReportFilter]] = ( + [ + ( + InboundReportList.PhoneNumberReportFilter(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("filters") + ] + if payload.get("filters") is not None + else None + ) + self.size: Optional[int] = payload.get("size") + + def to_dict(self): + return { + "time_range": ( + self.time_range.to_dict() if self.time_range is not None else None + ), + "filters": ( + [filters.to_dict() for filters in self.filters] + if self.filters is not None + else None + ), + "size": self.size, + } + + class ReportFilter(object): + """ + :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent' + :ivar values: List of supported filter values for the field name + """ + + def __init__(self, payload: Dict[str, Any]): + + self.key: Optional[str] = payload.get("key") + self.values: Optional[List[str]] = payload.get("values") + + def to_dict(self): + return { + "key": self.key, + "values": self.values, + } + + class ReportStatus(object): + CREATED = "created" + RUNNING = "running" + COMPLETED = "completed" + + """ + :ivar account_sid: The unique SID identifier of the Account. + :ivar report_id: The report identifier as Voice Insights Report TTID. + :ivar status: + :ivar request_meta: + :ivar url: The URL of this resource. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.report_id: Optional[str] = payload.get("report_id") + self.status: Optional["InboundReportInstance.ReportStatus"] = payload.get( + "status" + ) + self.request_meta: Optional[str] = payload.get("request_meta") + self.url: Optional[str] = payload.get("url") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class OutboundReportList(ListResource): + + class InsightsV2CreatePhoneNumbersReportRequest(object): + """ + :ivar time_range: + :ivar filters: + :ivar size: The number of max available top Phone Numbers to generate. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.time_range: Optional[ + InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange + ] = ( + InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange( + payload.get("time_range") + ) + if payload.get("time_range") is not None + else None + ) + self.filters: Optional[List[InboundReportList.PhoneNumberReportFilter]] = ( + [ + ( + InboundReportList.PhoneNumberReportFilter(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("filters") + ] + if payload.get("filters") is not None + else None + ) + self.size: Optional[int] = payload.get("size") + + def to_dict(self): + return { + "time_range": ( + self.time_range.to_dict() if self.time_range is not None else None + ), + "filters": ( + [filters.to_dict() for filters in self.filters] + if self.filters is not None + else None + ), + "size": self.size, + } + + class ReportFilter(object): + """ + :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent' + :ivar values: List of supported filter values for the field name + """ + + def __init__(self, payload: Dict[str, Any]): + + self.key: Optional[str] = payload.get("key") + self.values: Optional[List[str]] = payload.get("values") + + def to_dict(self): + return { + "key": self.key, + "values": self.values, + } + + def __init__(self, version: Version): + """ + Initialize the OutboundReportList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Voice/Reports/PhoneNumbers/Outbound" + + def _create( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = insights_v2_create_phone_numbers_report_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, data=data, headers=headers + ) + + def create( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> OutboundReportInstance: + """ + Create the OutboundReportInstance + + :param insights_v2_create_phone_numbers_report_request: + + :returns: The created OutboundReportInstance + """ + payload, _, _ = self._create( + insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request + ) + return OutboundReportInstance(self._version, payload) + + def create_with_http_info( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Create the OutboundReportInstance and return response metadata + + :param insights_v2_create_phone_numbers_report_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create( + insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request + ) + instance = OutboundReportInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = insights_v2_create_phone_numbers_report_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, data=data, headers=headers + ) + + async def create_async( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> OutboundReportInstance: + """ + Asynchronously create the OutboundReportInstance + + :param insights_v2_create_phone_numbers_report_request: + + :returns: The created OutboundReportInstance + """ + payload, _, _ = await self._create_async( + insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request + ) + return OutboundReportInstance(self._version, payload) + + async def create_with_http_info_async( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronously create the OutboundReportInstance and return response metadata + + :param insights_v2_create_phone_numbers_report_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async( + insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request + ) + instance = OutboundReportInstance(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/insights/v2/report.py b/twilio/rest/insights/v2/report.py index fb7df212e..1ade17bec 100644 --- a/twilio/rest/insights/v2/report.py +++ b/twilio/rest/insights/v2/report.py @@ -14,7 +14,7 @@ from datetime import datetime from typing import Any, Dict, List, Optional, Union -from twilio.base import deserialize, values +from twilio.base import values from twilio.base.api_response import ApiResponse from twilio.base.instance_context import InstanceContext from twilio.base.instance_resource import InstanceResource @@ -126,7 +126,13 @@ def __init__(self, payload: Dict[str, Any]): self.outbound_carrier_calling: Optional[ AccountReportKYTOutboundCarrierCalling - ] = payload.get("outbound_carrier_calling") + ] = ( + AccountReportKYTOutboundCarrierCalling( + payload.get("outbound_carrier_calling") + ) + if payload.get("outbound_carrier_calling") is not None + else None + ) def to_dict(self): return { @@ -159,7 +165,12 @@ def __init__(self, payload: Dict[str, Any]): "unique_called_numbers" ) self.blocked_calls_by_carrier: Optional[List[CountyCarrierValue]] = ( - payload.get("blocked_calls_by_carrier") + [ + CountyCarrierValue(item) if isinstance(item, dict) else item + for item in payload.get("blocked_calls_by_carrier") + ] + if payload.get("blocked_calls_by_carrier") is not None + else None ) self.short_duration_calls_percentage: Optional[float] = payload.get( "short_duration_calls_percentage" @@ -170,13 +181,21 @@ def __init__(self, payload: Dict[str, Any]): self.potential_robocalls_percentage: Optional[float] = payload.get( "potential_robocalls_percentage" ) - self.branded_calling: Optional[BrandedCalling] = payload.get( - "branded_calling" + self.branded_calling: Optional[BrandedCalling] = ( + BrandedCalling(payload.get("branded_calling")) + if payload.get("branded_calling") is not None + else None + ) + self.voice_integrity: Optional[VoiceIntegrity] = ( + VoiceIntegrity(payload.get("voice_integrity")) + if payload.get("voice_integrity") is not None + else None ) - self.voice_integrity: Optional[VoiceIntegrity] = payload.get( - "voice_integrity" + self.stir_shaken: Optional[StirShaken] = ( + StirShaken(payload.get("stir_shaken")) + if payload.get("stir_shaken") is not None + else None ) - self.stir_shaken: Optional[StirShaken] = payload.get("stir_shaken") def to_dict(self): return { @@ -216,9 +235,15 @@ class AccountReportNetworkIssues(object): def __init__(self, payload: Dict[str, Any]): - self.sdk: Optional[AccountReportNetworkIssuesSdk] = payload.get("sdk") + self.sdk: Optional[AccountReportNetworkIssuesSdk] = ( + AccountReportNetworkIssuesSdk(payload.get("sdk")) + if payload.get("sdk") is not None + else None + ) self.twilio_gateway: Optional[AccountReportNetworkIssuesTwilioGateway] = ( - payload.get("twilio_gateway") + AccountReportNetworkIssuesTwilioGateway(payload.get("twilio_gateway")) + if payload.get("twilio_gateway") is not None + else None ) def to_dict(self): @@ -307,8 +332,13 @@ def __init__(self, payload: Dict[str, Any]): self.answer_rate: Optional[float] = payload.get("answer_rate") self.human_answer_rate: Optional[float] = payload.get("human_answer_rate") self.engagement_rate: Optional[float] = payload.get("engagement_rate") - self.by_use_case: Optional[List[BrandedUseCaseDetail]] = payload.get( - "by_use_case" + self.by_use_case: Optional[List[BrandedUseCaseDetail]] = ( + [ + BrandedUseCaseDetail(item) if isinstance(item, dict) else item + for item in payload.get("by_use_case") + ] + if payload.get("by_use_case") is not None + else None ) def to_dict(self): @@ -391,9 +421,20 @@ def __init__(self, payload: Dict[str, Any]): self.time_range: Optional[ ReportList.InsightsV2CreateAccountReportRequestTimeRange - ] = payload.get("time_range") - self.filters: Optional[List[ReportList.ReportFilter]] = payload.get( - "filters" + ] = ( + ReportList.InsightsV2CreateAccountReportRequestTimeRange( + payload.get("time_range") + ) + if payload.get("time_range") is not None + else None + ) + self.filters: Optional[List[ReportList.ReportFilter]] = ( + [ + ReportList.ReportFilter(item) if isinstance(item, dict) else item + for item in payload.get("filters") + ] + if payload.get("filters") is not None + else None ) def to_dict(self): @@ -451,10 +492,20 @@ class StirShaken(object): def __init__(self, payload: Dict[str, Any]): - self.call_count: Optional[StirShakenCallCount] = payload.get("call_count") - self.percentage: Optional[StirShakenPercentage] = payload.get("percentage") - self.answer_rate: Optional[StirShakenAnswerRate] = payload.get( - "answer_rate" + self.call_count: Optional[StirShakenCallCount] = ( + StirShakenCallCount(payload.get("call_count")) + if payload.get("call_count") is not None + else None + ) + self.percentage: Optional[StirShakenPercentage] = ( + StirShakenPercentage(payload.get("percentage")) + if payload.get("percentage") is not None + else None + ) + self.answer_rate: Optional[StirShakenAnswerRate] = ( + StirShakenAnswerRate(payload.get("answer_rate")) + if payload.get("answer_rate") is not None + else None ) def to_dict(self): @@ -542,7 +593,16 @@ def __init__(self, payload: Dict[str, Any]): self.enabled_calls: Optional[int] = payload.get("enabled_calls") self.enabled_percentage: Optional[float] = payload.get("enabled_percentage") self.calls_per_bundle: Optional[List[VoiceIntegrityCallsPerBundle]] = ( - payload.get("calls_per_bundle") + [ + ( + VoiceIntegrityCallsPerBundle(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("calls_per_bundle") + ] + if payload.get("calls_per_bundle") is not None + else None ) def to_dict(self): @@ -598,18 +658,6 @@ class ReportStatus(object): :ivar status: :ivar request_meta: :ivar url: The URL of this resource. - :ivar handle: Inbound phone number handle represented in the report. - :ivar total_calls: Total number of calls made with the given handle during the report period. - :ivar call_answer_score: The call answer score measures customers behavior to the delivered calls. The score is a value between 0 and 100, where 100 indicates that all calls were successfully answered. - :ivar call_state_percentage: - :ivar silent_calls_percentage: Percentage of inbound calls with silence tags over total outbound calls. A silent tag is indicative of a connectivity issue or muted audio. - :ivar calls_by_device_type: Number of calls made with each device type. `voip`, `mobile`, `landline`, `unknown` - :ivar answer_rate_device_type: Answer rate for each device type. `voip`, `mobile`, `landline`, `unknown` - :ivar blocked_calls_by_carrier: Percentage of blocked calls by carrier per country. - :ivar short_duration_calls_percentage: Percentage of completed outbound calls under 10 seconds (PSTN Short call tags); More than 15% is typically low trust measured. - :ivar long_duration_calls_percentage: Percentage of long duration calls ( >= 60 seconds) - :ivar potential_robocalls_percentage: Percentage of completed outbound calls to unassigned or unallocated phone numbers. - :ivar answering_machine_detection: :ivar report: """ @@ -620,39 +668,11 @@ def __init__( self.account_sid: Optional[str] = payload.get("account_sid") self.report_id: Optional[str] = payload.get("report_id") - self.status: Optional["InboundInstance.str"] = payload.get("status") + self.status: Optional["InboundReportInstance.ReportStatus"] = payload.get( + "status" + ) self.request_meta: Optional[str] = payload.get("request_meta") self.url: Optional[str] = payload.get("url") - self.handle: Optional[str] = payload.get("handle") - self.total_calls: Optional[int] = deserialize.integer( - payload.get("total_calls") - ) - self.call_answer_score: Optional[float] = payload.get("call_answer_score") - self.call_state_percentage: Optional[str] = payload.get("call_state_percentage") - self.silent_calls_percentage: Optional[float] = payload.get( - "silent_calls_percentage" - ) - self.calls_by_device_type: Optional[Dict[str, int]] = payload.get( - "calls_by_device_type" - ) - self.answer_rate_device_type: Optional[Dict[str, float]] = payload.get( - "answer_rate_device_type" - ) - self.blocked_calls_by_carrier: Optional[List[str]] = payload.get( - "blocked_calls_by_carrier" - ) - self.short_duration_calls_percentage: Optional[float] = payload.get( - "short_duration_calls_percentage" - ) - self.long_duration_calls_percentage: Optional[float] = payload.get( - "long_duration_calls_percentage" - ) - self.potential_robocalls_percentage: Optional[float] = payload.get( - "potential_robocalls_percentage" - ) - self.answering_machine_detection: Optional[str] = payload.get( - "answering_machine_detection" - ) self.report: Optional[str] = payload.get("report") self._solution = { @@ -676,74 +696,6 @@ def _proxy(self) -> "ReportContext": ) return self._context - def create( - self, - insights_v2_create_account_report_request: Union[ - InsightsV2CreateAccountReportRequest, object - ] = values.unset, - ) -> "ReportInstance": - """ - Create the ReportInstance - - :param insights_v2_create_account_report_request: - - :returns: The created ReportInstance - """ - return self._proxy.create( - insights_v2_create_account_report_request=insights_v2_create_account_report_request, - ) - - async def create_async( - self, - insights_v2_create_account_report_request: Union[ - InsightsV2CreateAccountReportRequest, object - ] = values.unset, - ) -> "ReportInstance": - """ - Asynchronous coroutine to create the ReportInstance - - :param insights_v2_create_account_report_request: - - :returns: The created ReportInstance - """ - return await self._proxy.create_async( - insights_v2_create_account_report_request=insights_v2_create_account_report_request, - ) - - def create_with_http_info( - self, - insights_v2_create_account_report_request: Union[ - InsightsV2CreateAccountReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Create the ReportInstance with HTTP info - - :param insights_v2_create_account_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - return self._proxy.create_with_http_info( - insights_v2_create_account_report_request=insights_v2_create_account_report_request, - ) - - async def create_with_http_info_async( - self, - insights_v2_create_account_report_request: Union[ - InsightsV2CreateAccountReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronous coroutine to create the ReportInstance with HTTP info - - :param insights_v2_create_account_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - return await self._proxy.create_with_http_info_async( - insights_v2_create_account_report_request=insights_v2_create_account_report_request, - ) - def fetch(self) -> "ReportInstance": """ Fetch the ReportInstance @@ -894,7 +846,13 @@ def __init__(self, payload: Dict[str, Any]): self.outbound_carrier_calling: Optional[ AccountReportKYTOutboundCarrierCalling - ] = payload.get("outbound_carrier_calling") + ] = ( + AccountReportKYTOutboundCarrierCalling( + payload.get("outbound_carrier_calling") + ) + if payload.get("outbound_carrier_calling") is not None + else None + ) def to_dict(self): return { @@ -927,7 +885,12 @@ def __init__(self, payload: Dict[str, Any]): "unique_called_numbers" ) self.blocked_calls_by_carrier: Optional[List[CountyCarrierValue]] = ( - payload.get("blocked_calls_by_carrier") + [ + CountyCarrierValue(item) if isinstance(item, dict) else item + for item in payload.get("blocked_calls_by_carrier") + ] + if payload.get("blocked_calls_by_carrier") is not None + else None ) self.short_duration_calls_percentage: Optional[float] = payload.get( "short_duration_calls_percentage" @@ -938,13 +901,21 @@ def __init__(self, payload: Dict[str, Any]): self.potential_robocalls_percentage: Optional[float] = payload.get( "potential_robocalls_percentage" ) - self.branded_calling: Optional[BrandedCalling] = payload.get( - "branded_calling" + self.branded_calling: Optional[BrandedCalling] = ( + BrandedCalling(payload.get("branded_calling")) + if payload.get("branded_calling") is not None + else None + ) + self.voice_integrity: Optional[VoiceIntegrity] = ( + VoiceIntegrity(payload.get("voice_integrity")) + if payload.get("voice_integrity") is not None + else None ) - self.voice_integrity: Optional[VoiceIntegrity] = payload.get( - "voice_integrity" + self.stir_shaken: Optional[StirShaken] = ( + StirShaken(payload.get("stir_shaken")) + if payload.get("stir_shaken") is not None + else None ) - self.stir_shaken: Optional[StirShaken] = payload.get("stir_shaken") def to_dict(self): return { @@ -984,9 +955,15 @@ class AccountReportNetworkIssues(object): def __init__(self, payload: Dict[str, Any]): - self.sdk: Optional[AccountReportNetworkIssuesSdk] = payload.get("sdk") + self.sdk: Optional[AccountReportNetworkIssuesSdk] = ( + AccountReportNetworkIssuesSdk(payload.get("sdk")) + if payload.get("sdk") is not None + else None + ) self.twilio_gateway: Optional[AccountReportNetworkIssuesTwilioGateway] = ( - payload.get("twilio_gateway") + AccountReportNetworkIssuesTwilioGateway(payload.get("twilio_gateway")) + if payload.get("twilio_gateway") is not None + else None ) def to_dict(self): @@ -1075,8 +1052,13 @@ def __init__(self, payload: Dict[str, Any]): self.answer_rate: Optional[float] = payload.get("answer_rate") self.human_answer_rate: Optional[float] = payload.get("human_answer_rate") self.engagement_rate: Optional[float] = payload.get("engagement_rate") - self.by_use_case: Optional[List[BrandedUseCaseDetail]] = payload.get( - "by_use_case" + self.by_use_case: Optional[List[BrandedUseCaseDetail]] = ( + [ + BrandedUseCaseDetail(item) if isinstance(item, dict) else item + for item in payload.get("by_use_case") + ] + if payload.get("by_use_case") is not None + else None ) def to_dict(self): @@ -1159,9 +1141,20 @@ def __init__(self, payload: Dict[str, Any]): self.time_range: Optional[ ReportList.InsightsV2CreateAccountReportRequestTimeRange - ] = payload.get("time_range") - self.filters: Optional[List[ReportList.ReportFilter]] = payload.get( - "filters" + ] = ( + ReportList.InsightsV2CreateAccountReportRequestTimeRange( + payload.get("time_range") + ) + if payload.get("time_range") is not None + else None + ) + self.filters: Optional[List[ReportList.ReportFilter]] = ( + [ + ReportList.ReportFilter(item) if isinstance(item, dict) else item + for item in payload.get("filters") + ] + if payload.get("filters") is not None + else None ) def to_dict(self): @@ -1219,10 +1212,20 @@ class StirShaken(object): def __init__(self, payload: Dict[str, Any]): - self.call_count: Optional[StirShakenCallCount] = payload.get("call_count") - self.percentage: Optional[StirShakenPercentage] = payload.get("percentage") - self.answer_rate: Optional[StirShakenAnswerRate] = payload.get( - "answer_rate" + self.call_count: Optional[StirShakenCallCount] = ( + StirShakenCallCount(payload.get("call_count")) + if payload.get("call_count") is not None + else None + ) + self.percentage: Optional[StirShakenPercentage] = ( + StirShakenPercentage(payload.get("percentage")) + if payload.get("percentage") is not None + else None + ) + self.answer_rate: Optional[StirShakenAnswerRate] = ( + StirShakenAnswerRate(payload.get("answer_rate")) + if payload.get("answer_rate") is not None + else None ) def to_dict(self): @@ -1310,7 +1313,16 @@ def __init__(self, payload: Dict[str, Any]): self.enabled_calls: Optional[int] = payload.get("enabled_calls") self.enabled_percentage: Optional[float] = payload.get("enabled_percentage") self.calls_per_bundle: Optional[List[VoiceIntegrityCallsPerBundle]] = ( - payload.get("calls_per_bundle") + [ + ( + VoiceIntegrityCallsPerBundle(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("calls_per_bundle") + ] + if payload.get("calls_per_bundle") is not None + else None ) def to_dict(self): @@ -1370,136 +1382,6 @@ def __init__(self, version: Version, report_id: str): } self._uri = "/Voice/Reports/{report_id}".format(**self._solution) - def _create( - self, - insights_v2_create_account_report_request: Union[ - InsightsV2CreateAccountReportRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_v2_create_account_report_request.to_dict() - - headers = values.of({}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return self._version.create_with_response_info( - method="POST", uri=self._uri, data=data, headers=headers - ) - - def create( - self, - insights_v2_create_account_report_request: Union[ - InsightsV2CreateAccountReportRequest, object - ] = values.unset, - ) -> ReportInstance: - """ - Create the ReportInstance - - :param insights_v2_create_account_report_request: - - :returns: The created ReportInstance - """ - payload, _, _ = self._create( - insights_v2_create_account_report_request=insights_v2_create_account_report_request - ) - return ReportInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - - def create_with_http_info( - self, - insights_v2_create_account_report_request: Union[ - InsightsV2CreateAccountReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Create the ReportInstance and return response metadata - - :param insights_v2_create_account_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create( - insights_v2_create_account_report_request=insights_v2_create_account_report_request - ) - instance = ReportInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _create_async( - self, - insights_v2_create_account_report_request: Union[ - InsightsV2CreateAccountReportRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal async helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_v2_create_account_report_request.to_dict() - - headers = values.of({}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - async def create_async( - self, - insights_v2_create_account_report_request: Union[ - InsightsV2CreateAccountReportRequest, object - ] = values.unset, - ) -> ReportInstance: - """ - Asynchronous coroutine to create the ReportInstance - - :param insights_v2_create_account_report_request: - - :returns: The created ReportInstance - """ - payload, _, _ = await self._create_async( - insights_v2_create_account_report_request=insights_v2_create_account_report_request - ) - return ReportInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - - async def create_with_http_info_async( - self, - insights_v2_create_account_report_request: Union[ - InsightsV2CreateAccountReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronous coroutine to create the ReportInstance and return response metadata - - :param insights_v2_create_account_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async( - insights_v2_create_account_report_request=insights_v2_create_account_report_request - ) - instance = ReportInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - def _fetch(self) -> tuple: """ Internal helper for fetch operation @@ -1704,7 +1586,13 @@ def __init__(self, payload: Dict[str, Any]): self.outbound_carrier_calling: Optional[ AccountReportKYTOutboundCarrierCalling - ] = payload.get("outbound_carrier_calling") + ] = ( + AccountReportKYTOutboundCarrierCalling( + payload.get("outbound_carrier_calling") + ) + if payload.get("outbound_carrier_calling") is not None + else None + ) def to_dict(self): return { @@ -1737,7 +1625,12 @@ def __init__(self, payload: Dict[str, Any]): "unique_called_numbers" ) self.blocked_calls_by_carrier: Optional[List[CountyCarrierValue]] = ( - payload.get("blocked_calls_by_carrier") + [ + CountyCarrierValue(item) if isinstance(item, dict) else item + for item in payload.get("blocked_calls_by_carrier") + ] + if payload.get("blocked_calls_by_carrier") is not None + else None ) self.short_duration_calls_percentage: Optional[float] = payload.get( "short_duration_calls_percentage" @@ -1748,13 +1641,21 @@ def __init__(self, payload: Dict[str, Any]): self.potential_robocalls_percentage: Optional[float] = payload.get( "potential_robocalls_percentage" ) - self.branded_calling: Optional[BrandedCalling] = payload.get( - "branded_calling" + self.branded_calling: Optional[BrandedCalling] = ( + BrandedCalling(payload.get("branded_calling")) + if payload.get("branded_calling") is not None + else None ) - self.voice_integrity: Optional[VoiceIntegrity] = payload.get( - "voice_integrity" + self.voice_integrity: Optional[VoiceIntegrity] = ( + VoiceIntegrity(payload.get("voice_integrity")) + if payload.get("voice_integrity") is not None + else None + ) + self.stir_shaken: Optional[StirShaken] = ( + StirShaken(payload.get("stir_shaken")) + if payload.get("stir_shaken") is not None + else None ) - self.stir_shaken: Optional[StirShaken] = payload.get("stir_shaken") def to_dict(self): return { @@ -1794,9 +1695,15 @@ class AccountReportNetworkIssues(object): def __init__(self, payload: Dict[str, Any]): - self.sdk: Optional[AccountReportNetworkIssuesSdk] = payload.get("sdk") + self.sdk: Optional[AccountReportNetworkIssuesSdk] = ( + AccountReportNetworkIssuesSdk(payload.get("sdk")) + if payload.get("sdk") is not None + else None + ) self.twilio_gateway: Optional[AccountReportNetworkIssuesTwilioGateway] = ( - payload.get("twilio_gateway") + AccountReportNetworkIssuesTwilioGateway(payload.get("twilio_gateway")) + if payload.get("twilio_gateway") is not None + else None ) def to_dict(self): @@ -1885,8 +1792,13 @@ def __init__(self, payload: Dict[str, Any]): self.answer_rate: Optional[float] = payload.get("answer_rate") self.human_answer_rate: Optional[float] = payload.get("human_answer_rate") self.engagement_rate: Optional[float] = payload.get("engagement_rate") - self.by_use_case: Optional[List[BrandedUseCaseDetail]] = payload.get( - "by_use_case" + self.by_use_case: Optional[List[BrandedUseCaseDetail]] = ( + [ + BrandedUseCaseDetail(item) if isinstance(item, dict) else item + for item in payload.get("by_use_case") + ] + if payload.get("by_use_case") is not None + else None ) def to_dict(self): @@ -1969,9 +1881,20 @@ def __init__(self, payload: Dict[str, Any]): self.time_range: Optional[ ReportList.InsightsV2CreateAccountReportRequestTimeRange - ] = payload.get("time_range") - self.filters: Optional[List[ReportList.ReportFilter]] = payload.get( - "filters" + ] = ( + ReportList.InsightsV2CreateAccountReportRequestTimeRange( + payload.get("time_range") + ) + if payload.get("time_range") is not None + else None + ) + self.filters: Optional[List[ReportList.ReportFilter]] = ( + [ + ReportList.ReportFilter(item) if isinstance(item, dict) else item + for item in payload.get("filters") + ] + if payload.get("filters") is not None + else None ) def to_dict(self): @@ -2029,10 +1952,20 @@ class StirShaken(object): def __init__(self, payload: Dict[str, Any]): - self.call_count: Optional[StirShakenCallCount] = payload.get("call_count") - self.percentage: Optional[StirShakenPercentage] = payload.get("percentage") - self.answer_rate: Optional[StirShakenAnswerRate] = payload.get( - "answer_rate" + self.call_count: Optional[StirShakenCallCount] = ( + StirShakenCallCount(payload.get("call_count")) + if payload.get("call_count") is not None + else None + ) + self.percentage: Optional[StirShakenPercentage] = ( + StirShakenPercentage(payload.get("percentage")) + if payload.get("percentage") is not None + else None + ) + self.answer_rate: Optional[StirShakenAnswerRate] = ( + StirShakenAnswerRate(payload.get("answer_rate")) + if payload.get("answer_rate") is not None + else None ) def to_dict(self): @@ -2120,7 +2053,16 @@ def __init__(self, payload: Dict[str, Any]): self.enabled_calls: Optional[int] = payload.get("enabled_calls") self.enabled_percentage: Optional[float] = payload.get("enabled_percentage") self.calls_per_bundle: Optional[List[VoiceIntegrityCallsPerBundle]] = ( - payload.get("calls_per_bundle") + [ + ( + VoiceIntegrityCallsPerBundle(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("calls_per_bundle") + ] + if payload.get("calls_per_bundle") is not None + else None ) def to_dict(self): @@ -2174,6 +2116,130 @@ def __init__(self, version: Version): """ super().__init__(version) + self._uri = "/Voice/Reports" + + def _create( + self, + insights_v2_create_account_report_request: Union[ + InsightsV2CreateAccountReportRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = insights_v2_create_account_report_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, data=data, headers=headers + ) + + def create( + self, + insights_v2_create_account_report_request: Union[ + InsightsV2CreateAccountReportRequest, object + ] = values.unset, + ) -> ReportInstance: + """ + Create the ReportInstance + + :param insights_v2_create_account_report_request: + + :returns: The created ReportInstance + """ + payload, _, _ = self._create( + insights_v2_create_account_report_request=insights_v2_create_account_report_request + ) + return ReportInstance(self._version, payload) + + def create_with_http_info( + self, + insights_v2_create_account_report_request: Union[ + InsightsV2CreateAccountReportRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Create the ReportInstance and return response metadata + + :param insights_v2_create_account_report_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create( + insights_v2_create_account_report_request=insights_v2_create_account_report_request + ) + instance = ReportInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async( + self, + insights_v2_create_account_report_request: Union[ + InsightsV2CreateAccountReportRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = insights_v2_create_account_report_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, data=data, headers=headers + ) + + async def create_async( + self, + insights_v2_create_account_report_request: Union[ + InsightsV2CreateAccountReportRequest, object + ] = values.unset, + ) -> ReportInstance: + """ + Asynchronously create the ReportInstance + + :param insights_v2_create_account_report_request: + + :returns: The created ReportInstance + """ + payload, _, _ = await self._create_async( + insights_v2_create_account_report_request=insights_v2_create_account_report_request + ) + return ReportInstance(self._version, payload) + + async def create_with_http_info_async( + self, + insights_v2_create_account_report_request: Union[ + InsightsV2CreateAccountReportRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronously create the ReportInstance and return response metadata + + :param insights_v2_create_account_report_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async( + insights_v2_create_account_report_request=insights_v2_create_account_report_request + ) + instance = ReportInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + def get(self, report_id: str) -> ReportContext: """ Constructs a ReportContext diff --git a/twilio/rest/insights/v3/__init__.py b/twilio/rest/insights/v3/__init__.py index 293980816..18b2d1e12 100644 --- a/twilio/rest/insights/v3/__init__.py +++ b/twilio/rest/insights/v3/__init__.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio - Insights - Insights Domain V3 API. Includes synchronous Query, Metadata, and Async Query (long-running operation) endpoints. + The Twilio Insights v3 API provides semantic query access to Conversations analytics data. Resources include synchronous Query, Metadata, and asynchronous QueryJobs for long-running queries. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech diff --git a/twilio/rest/insights/v3/metadata.py b/twilio/rest/insights/v3/metadata.py index 30e8d8f11..93857fd90 100644 --- a/twilio/rest/insights/v3/metadata.py +++ b/twilio/rest/insights/v3/metadata.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio - Insights - Insights Domain V3 API. Includes synchronous Query, Metadata, and Async Query (long-running operation) endpoints. + The Twilio Insights v3 API provides semantic query access to Conversations analytics data. Resources include synchronous Query, Metadata, and asynchronous QueryJobs for long-running queries. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech diff --git a/twilio/rest/insights/v3/query.py b/twilio/rest/insights/v3/query.py index b65b0aaec..35b079ccc 100644 --- a/twilio/rest/insights/v3/query.py +++ b/twilio/rest/insights/v3/query.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio - Insights - Insights Domain V3 API. Includes synchronous Query, Metadata, and Async Query (long-running operation) endpoints. + The Twilio Insights v3 API provides semantic query access to Conversations analytics data. Resources include synchronous Query, Metadata, and asynchronous QueryJobs for long-running queries. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech @@ -34,7 +34,9 @@ def __init__(self, version: Version, payload: Dict[str, Any]): super().__init__(version) self.domain: Optional[str] = payload.get("domain") - self.items: Optional[List[Dict[str, object]]] = payload.get("items") + self.items: Optional[List[Dict[str, Dict[str, Dict[str, object]]]]] = ( + payload.get("items") + ) self.meta: Optional[str] = payload.get("meta") def __repr__(self) -> str: @@ -58,7 +60,11 @@ class InsightsQueryRequest(object): def __init__(self, payload: Dict[str, Any]): self.domain: Optional[str] = payload.get("domain") - self.query: Optional[QueryList.QueryDefinition] = payload.get("query") + self.query: Optional[QueryList.QueryDefinition] = ( + QueryList.QueryDefinition(payload.get("query")) + if payload.get("query") is not None + else None + ) def to_dict(self): return { @@ -79,10 +85,28 @@ def __init__(self, payload: Dict[str, Any]): self.measures: Optional[List[str]] = payload.get("measures") self.dimensions: Optional[List[str]] = payload.get("dimensions") self.filters: Optional[List[QueryList.QueryDefinitionFilters]] = ( - payload.get("filters") + [ + ( + QueryList.QueryDefinitionFilters(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("filters") + ] + if payload.get("filters") is not None + else None ) self.order_by: Optional[List[QueryList.QueryDefinitionOrderBy]] = ( - payload.get("orderBy") + [ + ( + QueryList.QueryDefinitionOrderBy(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("orderBy") + ] + if payload.get("orderBy") is not None + else None ) def to_dict(self): @@ -109,10 +133,21 @@ class QueryDefinitionFilters(object): def __init__(self, payload: Dict[str, Any]): - self.op: Optional["QueryInstance.str"] = payload.get("op") + self.op: Optional[str] = payload.get("op") self.expressions: Optional[ List[QueryList.QueryDefinitionFiltersExpressions] - ] = payload.get("expressions") + ] = ( + [ + ( + QueryList.QueryDefinitionFiltersExpressions(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("expressions") + ] + if payload.get("expressions") is not None + else None + ) def to_dict(self): return { @@ -133,7 +168,7 @@ class QueryDefinitionFiltersExpressions(object): def __init__(self, payload: Dict[str, Any]): - self.op: Optional["QueryInstance.str"] = payload.get("op") + self.op: Optional[str] = payload.get("op") self.field: Optional[str] = payload.get("field") self.values: Optional[List[str]] = payload.get("values") @@ -153,7 +188,7 @@ class QueryDefinitionOrderBy(object): def __init__(self, payload: Dict[str, Any]): self.field: Optional[str] = payload.get("field") - self.direction: Optional["QueryInstance.str"] = payload.get("direction") + self.direction: Optional[str] = payload.get("direction") def to_dict(self): return { diff --git a/twilio/rest/insights/v3/query_job.py b/twilio/rest/insights/v3/query_job.py index 893dce976..66c25e084 100644 --- a/twilio/rest/insights/v3/query_job.py +++ b/twilio/rest/insights/v3/query_job.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio - Insights - Insights Domain V3 API. Includes synchronous Query, Metadata, and Async Query (long-running operation) endpoints. + The Twilio Insights v3 API provides semantic query access to Conversations analytics data. Resources include synchronous Query, Metadata, and asynchronous QueryJobs for long-running queries. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech @@ -35,20 +35,21 @@ class LongRunningOperationStatus(object): FAILED = "FAILED" """ - :ivar operation_id: + :ivar operation_id: The unique identifier for the asynchronous query operation, in TTID format. :ivar status: :ivar status_url: :ivar created_at: - :ivar completed_at: When the operation reached a terminal state. - :ivar error: Error details. Present only when status is FAILED. - :ivar result_url: URL to retrieve query results. Present only when status is COMPLETED. Supports pagination via pageSize and pageToken query parameters. - :ivar result_retention_period: ISO 8601 duration for how long results are retained. + :ivar completed_at: The time when the operation reached a terminal state (CANCELLED, COMPLETED, or FAILED), in RFC 3339 UTC format. Null while the operation is still PENDING or RUNNING. + :ivar error: The error details, present only when status is FAILED. + :ivar result_url: The URL to retrieve query results, present only when status is COMPLETED. Supports pagination via the pageSize and pageToken query parameters. + :ivar result_id: The identifier of the results resource, present only when status is COMPLETED. Equal to operationId, since results are keyed by the operation ID. + :ivar result_retention_period: The duration for how long results are retained, in ISO 8601 format. """ def __init__( self, version: Version, - payload: ResponseResource, + payload: Dict[str, Any], operation_id: Optional[str] = None, ): super().__init__(version) @@ -66,6 +67,7 @@ def __init__( ) self.error: Optional[OperationError] = payload.get("error") self.result_url: Optional[str] = payload.get("resultUrl") + self.result_id: Optional[str] = payload.get("resultId") self.result_retention_period: Optional[str] = payload.get( "resultRetentionPeriod" ) @@ -146,7 +148,7 @@ def __init__(self, version: Version, operation_id: str): Initialize the QueryJobContext :param version: Version that contains the resource - :param operation_id: The unique identifier for the async query operation (TTID format). + :param operation_id: The unique identifier for the asynchronous query operation, in TTID format. """ super().__init__(version) @@ -289,7 +291,11 @@ class InsightsQueryRequest(object): def __init__(self, payload: Dict[str, Any]): self.domain: Optional[str] = payload.get("domain") - self.query: Optional[QueryList.QueryDefinition] = payload.get("query") + self.query: Optional[QueryList.QueryDefinition] = ( + QueryList.QueryDefinition(payload.get("query")) + if payload.get("query") is not None + else None + ) def to_dict(self): return { @@ -320,101 +326,6 @@ def to_dict(self): "detail": self.detail, } - class QueryDefinition(object): - """ - :ivar measures: Array of measures to retrieve, representing quantitative values or metrics to be calculated - :ivar dimensions: Array of dimensions to retrieve, representing categorical attributes for grouping and organizing data - :ivar filters: Nested filter conditions. Always use `op` and `expressions`. - :ivar order_by: Specifications for sorting the query results by specific fields in ascending or descending order - """ - - def __init__(self, payload: Dict[str, Any]): - - self.measures: Optional[List[str]] = payload.get("measures") - self.dimensions: Optional[List[str]] = payload.get("dimensions") - self.filters: Optional[List[QueryList.QueryDefinitionFilters]] = ( - payload.get("filters") - ) - self.order_by: Optional[List[QueryList.QueryDefinitionOrderBy]] = ( - payload.get("orderBy") - ) - - def to_dict(self): - return { - "measures": self.measures, - "dimensions": self.dimensions, - "filters": ( - [filters.to_dict() for filters in self.filters] - if self.filters is not None - else None - ), - "orderBy": ( - [order_by.to_dict() for order_by in self.order_by] - if self.order_by is not None - else None - ), - } - - class QueryDefinitionFilters(object): - """ - :ivar op: - :ivar expressions: - """ - - def __init__(self, payload: Dict[str, Any]): - - self.op: Optional["QueryInstance.str"] = payload.get("op") - self.expressions: Optional[ - List[QueryList.QueryDefinitionFiltersExpressions] - ] = payload.get("expressions") - - def to_dict(self): - return { - "op": self.op, - "expressions": ( - [expressions.to_dict() for expressions in self.expressions] - if self.expressions is not None - else None - ), - } - - class QueryDefinitionFiltersExpressions(object): - """ - :ivar op: - :ivar field: - :ivar values: - """ - - def __init__(self, payload: Dict[str, Any]): - - self.op: Optional["QueryInstance.str"] = payload.get("op") - self.field: Optional[str] = payload.get("field") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "op": self.op, - "field": self.field, - "values": self.values, - } - - class QueryDefinitionOrderBy(object): - """ - :ivar field: Dimension or measure to order by - :ivar direction: Sort order direction, ascending or descending - """ - - def __init__(self, payload: Dict[str, Any]): - - self.field: Optional[str] = payload.get("field") - self.direction: Optional["QueryInstance.str"] = payload.get("direction") - - def to_dict(self): - return { - "field": self.field, - "direction": self.direction, - } - def __init__(self, version: Version): """ Initialize the QueryJobList @@ -463,7 +374,7 @@ def create( Create the QueryJobInstance :param insights_query_request: - :param idempotency_key: Client-generated UUIDv7 key to ensure idempotent behavior. Submitting the same key for identical requests returns the same operation without re-execution. Scoped to Account + Region. Retained for 24 hours. + :param idempotency_key: A client-generated UUIDv7 key that ensures idempotent behavior. Submitting the same key with an identical request returns the same operation without re-execution. Scoped to Account + Region. Retained for 24 hours. :returns: The created QueryJobInstance """ @@ -482,7 +393,7 @@ def create_with_http_info( Create the QueryJobInstance and return response metadata :param insights_query_request: - :param idempotency_key: Client-generated UUIDv7 key to ensure idempotent behavior. Submitting the same key for identical requests returns the same operation without re-execution. Scoped to Account + Region. Retained for 24 hours. + :param idempotency_key: A client-generated UUIDv7 key that ensures idempotent behavior. Submitting the same key with an identical request returns the same operation without re-execution. Scoped to Account + Region. Retained for 24 hours. :returns: ApiResponse with instance, status code, and headers """ @@ -530,7 +441,7 @@ async def create_async( Asynchronously create the QueryJobInstance :param insights_query_request: - :param idempotency_key: Client-generated UUIDv7 key to ensure idempotent behavior. Submitting the same key for identical requests returns the same operation without re-execution. Scoped to Account + Region. Retained for 24 hours. + :param idempotency_key: A client-generated UUIDv7 key that ensures idempotent behavior. Submitting the same key with an identical request returns the same operation without re-execution. Scoped to Account + Region. Retained for 24 hours. :returns: The created QueryJobInstance """ @@ -549,7 +460,7 @@ async def create_with_http_info_async( Asynchronously create the QueryJobInstance and return response metadata :param insights_query_request: - :param idempotency_key: Client-generated UUIDv7 key to ensure idempotent behavior. Submitting the same key for identical requests returns the same operation without re-execution. Scoped to Account + Region. Retained for 24 hours. + :param idempotency_key: A client-generated UUIDv7 key that ensures idempotent behavior. Submitting the same key with an identical request returns the same operation without re-execution. Scoped to Account + Region. Retained for 24 hours. :returns: ApiResponse with instance, status code, and headers """ @@ -574,7 +485,7 @@ def stream( The results are returned as a generator, so this operation is memory efficient. :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. + :param LongRunningOperationStatus status: The operation status to filter results by. :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 @@ -605,7 +516,7 @@ async def stream_async( The results are returned as a generator, so this operation is memory efficient. :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. + :param LongRunningOperationStatus status: The operation status to filter results by. :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 @@ -634,7 +545,7 @@ def stream_with_http_info( :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. + :param LongRunningOperationStatus status: The operation status to filter results by. :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 @@ -664,7 +575,7 @@ async def stream_with_http_info_async( :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. + :param LongRunningOperationStatus status: The operation status to filter results by. :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 @@ -695,7 +606,7 @@ def list( memory before returning. :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. + :param LongRunningOperationStatus status: The operation status to filter results by. :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 @@ -728,7 +639,7 @@ async def list_async( memory before returning. :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. + :param LongRunningOperationStatus status: The operation status to filter results by. :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 @@ -761,7 +672,7 @@ def list_with_http_info( :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. + :param LongRunningOperationStatus status: The operation status to filter results by. :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 @@ -792,7 +703,7 @@ async def list_with_http_info_async( :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. + :param LongRunningOperationStatus status: The operation status to filter results by. :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 @@ -823,7 +734,7 @@ def page( :param page_size: The maximum number of resources to return :param page_token: Token for pagination - :param status: Filter by operation status. + :param status: The operation status to filter results by. :returns: Page of QueryJobInstance """ data = values.of( @@ -855,7 +766,7 @@ async def page_async( :param page_size: The maximum number of resources to return :param page_token: Token for pagination - :param status: Filter by operation status. + :param status: The operation status to filter results by. :returns: Page of QueryJobInstance """ data = values.of( @@ -887,7 +798,7 @@ def page_with_http_info( :param page_token: Token for pagination - :param status: Filter by operation status. + :param status: The operation status to filter results by. :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 @@ -926,7 +837,7 @@ async def page_with_http_info_async( :param page_token: Token for pagination - :param status: Filter by operation status. + :param status: The operation status to filter results by. :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 @@ -983,7 +894,7 @@ def get(self, operation_id: str) -> QueryJobContext: """ Constructs a QueryJobContext - :param operation_id: The unique identifier for the async query operation (TTID format). + :param operation_id: The unique identifier for the asynchronous query operation, in TTID format. """ return QueryJobContext(self._version, operation_id=operation_id) @@ -991,7 +902,7 @@ def __call__(self, operation_id: str) -> QueryJobContext: """ Constructs a QueryJobContext - :param operation_id: The unique identifier for the async query operation (TTID format). + :param operation_id: The unique identifier for the asynchronous query operation, in TTID format. """ return QueryJobContext(self._version, operation_id=operation_id) diff --git a/twilio/rest/insights/v3/result.py b/twilio/rest/insights/v3/result.py index 239c7208d..eecb3b642 100644 --- a/twilio/rest/insights/v3/result.py +++ b/twilio/rest/insights/v3/result.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio - Insights - Insights Domain V3 API. Includes synchronous Query, Metadata, and Async Query (long-running operation) endpoints. + The Twilio Insights v3 API provides semantic query access to Conversations analytics data. Resources include synchronous Query, Metadata, and asynchronous QueryJobs for long-running queries. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech @@ -34,7 +34,9 @@ def __init__(self, version: Version, payload: Dict[str, Any], operation_id: str) super().__init__(version) self.domain: Optional[str] = payload.get("domain") - self.items: Optional[List[Dict[str, object]]] = payload.get("items") + self.items: Optional[ + List[Dict[str, Dict[str, Dict[str, Dict[str, object]]]]] + ] = payload.get("items") self.meta: Optional[str] = payload.get("meta") # Only set _solution if path params are provided (not None) @@ -60,7 +62,7 @@ def __init__(self, version: Version, operation_id: str): Initialize the ResultList :param version: Version that contains the resource - :param operation_id: The unique identifier for the async query operation. + :param operation_id: The unique identifier for the asynchronous query operation, in TTID format. """ super().__init__(version) diff --git a/twilio/rest/intelligence/v2/transcript/operator_result.py b/twilio/rest/intelligence/v2/transcript/operator_result.py index 01af814a7..032c24590 100644 --- a/twilio/rest/intelligence/v2/transcript/operator_result.py +++ b/twilio/rest/intelligence/v2/transcript/operator_result.py @@ -71,8 +71,8 @@ def __init__( payload.get("match_probability") ) self.normalized_result: Optional[str] = payload.get("normalized_result") - self.utterance_results: Optional[List[Dict[str, object]]] = payload.get( - "utterance_results" + self.utterance_results: Optional[List[Dict[str, Dict[str, object]]]] = ( + payload.get("utterance_results") ) self.utterance_match: Optional[bool] = payload.get("utterance_match") self.predicted_label: Optional[str] = payload.get("predicted_label") diff --git a/twilio/rest/intelligence/v3/configuration.py b/twilio/rest/intelligence/v3/configuration.py index d67f2057b..882848272 100644 --- a/twilio/rest/intelligence/v3/configuration.py +++ b/twilio/rest/intelligence/v3/configuration.py @@ -43,7 +43,7 @@ class ConfigurationInstance(InstanceResource): """ def __init__( - self, version: Version, payload: ResponseResource, id: Optional[str] = None + self, version: Version, payload: Dict[str, Any], id: Optional[str] = None ): super().__init__(version) @@ -554,8 +554,8 @@ class Action(object): def __init__(self, payload: Dict[str, Any]): - self.type: Optional["ConfigurationInstance.str"] = payload.get("type") - self.method: Optional["ConfigurationInstance.str"] = payload.get("method") + self.type: Optional[str] = payload.get("type") + self.method: Optional[str] = payload.get("method") self.url: Optional[str] = payload.get("url") def to_dict(self): @@ -573,11 +573,15 @@ class Context(object): def __init__(self, payload: Dict[str, Any]): - self.memory: Optional[ConfigurationList.ContextMemory] = payload.get( - "memory" + self.memory: Optional[ConfigurationList.ContextMemory] = ( + ConfigurationList.ContextMemory(payload.get("memory")) + if payload.get("memory") is not None + else None ) - self.knowledge: Optional[ConfigurationList.ContextKnowledge] = payload.get( - "knowledge" + self.knowledge: Optional[ConfigurationList.ContextKnowledge] = ( + ConfigurationList.ContextKnowledge(payload.get("knowledge")) + if payload.get("knowledge") is not None + else None ) def to_dict(self): @@ -628,7 +632,16 @@ def __init__(self, payload: Dict[str, Any]): self.display_name: Optional[str] = payload.get("displayName") self.description: Optional[str] = payload.get("description") self.rules: Optional[List[ConfigurationList.RuleCreationRequestPayload]] = ( - payload.get("rules") + [ + ( + ConfigurationList.RuleCreationRequestPayload(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("rules") + ] + if payload.get("rules") is not None + else None ) def to_dict(self): @@ -672,16 +685,35 @@ class RuleCreationRequestPayload(object): def __init__(self, payload: Dict[str, Any]): - self.operators: Optional[List[ConfigurationList.Operator]] = payload.get( - "operators" + self.operators: Optional[List[ConfigurationList.Operator]] = ( + [ + ConfigurationList.Operator(item) if isinstance(item, dict) else item + for item in payload.get("operators") + ] + if payload.get("operators") is not None + else None ) - self.triggers: Optional[List[ConfigurationList.Trigger]] = payload.get( - "triggers" + self.triggers: Optional[List[ConfigurationList.Trigger]] = ( + [ + ConfigurationList.Trigger(item) if isinstance(item, dict) else item + for item in payload.get("triggers") + ] + if payload.get("triggers") is not None + else None ) - self.actions: Optional[List[ConfigurationList.Action]] = payload.get( - "actions" + self.actions: Optional[List[ConfigurationList.Action]] = ( + [ + ConfigurationList.Action(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None + ) + self.context: Optional[ConfigurationList.Context] = ( + ConfigurationList.Context(payload.get("context")) + if payload.get("context") is not None + else None ) - self.context: Optional[ConfigurationList.Context] = payload.get("context") def to_dict(self): return { @@ -715,16 +747,35 @@ class RuleUpdateRequestPayload(object): def __init__(self, payload: Dict[str, Any]): self.id: Optional[str] = payload.get("id") - self.operators: Optional[List[ConfigurationList.Operator]] = payload.get( - "operators" + self.operators: Optional[List[ConfigurationList.Operator]] = ( + [ + ConfigurationList.Operator(item) if isinstance(item, dict) else item + for item in payload.get("operators") + ] + if payload.get("operators") is not None + else None + ) + self.triggers: Optional[List[ConfigurationList.Trigger]] = ( + [ + ConfigurationList.Trigger(item) if isinstance(item, dict) else item + for item in payload.get("triggers") + ] + if payload.get("triggers") is not None + else None ) - self.triggers: Optional[List[ConfigurationList.Trigger]] = payload.get( - "triggers" + self.actions: Optional[List[ConfigurationList.Action]] = ( + [ + ConfigurationList.Action(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) - self.actions: Optional[List[ConfigurationList.Action]] = payload.get( - "actions" + self.context: Optional[ConfigurationList.Context] = ( + ConfigurationList.Context(payload.get("context")) + if payload.get("context") is not None + else None ) - self.context: Optional[ConfigurationList.Context] = payload.get("context") def to_dict(self): return { @@ -755,9 +806,11 @@ class Trigger(object): def __init__(self, payload: Dict[str, Any]): - self.on: Optional["ConfigurationInstance.str"] = payload.get("on") + self.on: Optional[str] = payload.get("on") self.parameters: Optional[ConfigurationList.TriggerParameters] = ( - payload.get("parameters") + ConfigurationList.TriggerParameters(payload.get("parameters")) + if payload.get("parameters") is not None + else None ) def to_dict(self): @@ -794,7 +847,16 @@ def __init__(self, payload: Dict[str, Any]): self.display_name: Optional[str] = payload.get("displayName") self.description: Optional[str] = payload.get("description") self.rules: Optional[List[ConfigurationList.RuleUpdateRequestPayload]] = ( - payload.get("rules") + [ + ( + ConfigurationList.RuleUpdateRequestPayload(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("rules") + ] + if payload.get("rules") is not None + else None ) def to_dict(self): diff --git a/twilio/rest/intelligence/v3/conversation.py b/twilio/rest/intelligence/v3/conversation.py index 62faa0809..6bcb196a4 100644 --- a/twilio/rest/intelligence/v3/conversation.py +++ b/twilio/rest/intelligence/v3/conversation.py @@ -59,14 +59,16 @@ class ConversationStatus(object): """ def __init__( - self, version: Version, payload: ResponseResource, id: Optional[str] = None + self, version: Version, payload: Dict[str, Any], id: Optional[str] = None ): super().__init__(version) self.id: Optional[str] = payload.get("id") self.account_id: Optional[str] = payload.get("accountId") self.name: Optional[str] = payload.get("name") - self.status: Optional["ConversationInstance.str"] = payload.get("status") + self.status: Optional["ConversationInstance.ConversationStatus"] = payload.get( + "status" + ) self.created_at: Optional[datetime] = deserialize.iso8601_datetime( payload.get("createdAt") ) @@ -79,7 +81,9 @@ def __init__( self.conversation_configuration_id: Optional[str] = payload.get( "conversationConfigurationId" ) - self.channels: Optional[List[Enumstr]] = payload.get("channels") + self.channels: Optional[List["ConversationInstance.Channel"]] = payload.get( + "channels" + ) self.channel_ids: Optional[List[str]] = payload.get("channelIds") self.participants: Optional[List[str]] = payload.get("participants") self.communications: Optional[List[str]] = payload.get("communications") diff --git a/twilio/rest/intelligence/v3/operator.py b/twilio/rest/intelligence/v3/operator.py index cbd7499a5..64fc9f1cf 100644 --- a/twilio/rest/intelligence/v3/operator.py +++ b/twilio/rest/intelligence/v3/operator.py @@ -55,7 +55,7 @@ class OperatorOutputFormat(object): """ def __init__( - self, version: Version, payload: ResponseResource, id: Optional[str] = None + self, version: Version, payload: Dict[str, Any], id: Optional[str] = None ): super().__init__(version) @@ -78,8 +78,8 @@ def __init__( payload.get("trainingExamples") ) self.context: Optional[OperatorList.OperatorContext] = payload.get("context") - self.parameters: Optional[Dict[str, OperatorParameter]] = payload.get( - "parameters" + self.parameters: Optional[Dict[str, OperatorList.OperatorParameter]] = ( + payload.get("parameters") ) # Only set _solution if path params are provided (not None) @@ -631,12 +631,30 @@ def __init__(self, payload: Dict[str, Any]): ) self.training_examples: Optional[ List[OperatorList.OperatorTrainingExample] - ] = payload.get("trainingExamples") - self.context: Optional[OperatorList.OperatorContext] = payload.get( - "context" + ] = ( + [ + ( + OperatorList.OperatorTrainingExample(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("trainingExamples") + ] + if payload.get("trainingExamples") is not None + else None ) - self.parameters: Optional[Dict[str, OperatorParameter]] = payload.get( - "parameters" + self.context: Optional[OperatorList.OperatorContext] = ( + OperatorList.OperatorContext(payload.get("context")) + if payload.get("context") is not None + else None + ) + self.parameters: Optional[Dict[str, OperatorList.OperatorParameter]] = ( + { + k: OperatorList.OperatorParameter(v) if isinstance(v, dict) else v + for k, v in payload.get("parameters").items() + } + if payload.get("parameters") is not None + else None ) def to_dict(self): @@ -673,11 +691,15 @@ class OperatorContext(object): def __init__(self, payload: Dict[str, Any]): - self.memory: Optional[OperatorList.OperatorContextMemory] = payload.get( - "memory" + self.memory: Optional[OperatorList.OperatorContextMemory] = ( + OperatorList.OperatorContextMemory(payload.get("memory")) + if payload.get("memory") is not None + else None ) self.knowledge: Optional[OperatorList.OperatorContextKnowledge] = ( - payload.get("knowledge") + OperatorList.OperatorContextKnowledge(payload.get("knowledge")) + if payload.get("knowledge") is not None + else None ) def to_dict(self): @@ -716,6 +738,29 @@ def to_dict(self): "enabled": self.enabled, } + class OperatorParameter(object): + """ + :ivar type: The data type of the parameter (e.g., STRING, INTEGER). Available values: STRING, INTEGER, NUMBER, BOOLEAN, KNOWLEDGE_BASE_AND_SOURCE_IDS KNOWLEDGE_BASE_AND_SOURCE_IDS is a special type of parameter that refers to a Memora Knowledge Source, prefixed with its Knowledge Base container. Support for KB type = plaintext only. During Intelligence Configuration creation, this parameter is linked to a specific Knowledge Source. The operator receives the resolved plaintext at runtime and injects it into the prompt. The value of this parameter is expected to be passed in the following format: knowledge_base_id:knowledge_source_id. + :ivar default: Default value to use in the prompt if no value is provided by the Intelligence Configuration. Note: knowledge_base_and_source_ids does not support the default attribute, but all other param types do allow for a default value. + :ivar required: Whether this parameter must be set at Operator execution time. Defaults to false if not provided. + :ivar description: A human-readable description of the parameter. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.type: Optional[str] = payload.get("type") + self.default: Optional[Dict[str, object]] = payload.get("default") + self.required: Optional[bool] = payload.get("required") + self.description: Optional[str] = payload.get("description") + + def to_dict(self): + return { + "type": self.type, + "default": self.default, + "required": self.required, + "description": self.description, + } + class OperatorTrainingExample(object): """ :ivar input: A sample input text that demonstrates the type of content the Operator processes. diff --git a/twilio/rest/intelligence/v3/operator_result.py b/twilio/rest/intelligence/v3/operator_result.py index 1f649795d..5b4af287c 100644 --- a/twilio/rest/intelligence/v3/operator_result.py +++ b/twilio/rest/intelligence/v3/operator_result.py @@ -48,7 +48,7 @@ class OperatorResultInstance(InstanceResource): def __init__( self, version: Version, - payload: ResponseResource, + payload: Dict[str, Any], operator_result_id: Optional[str] = None, ): super().__init__(version) diff --git a/twilio/rest/intelligence/v3/version.py b/twilio/rest/intelligence/v3/version.py index b283dbf54..70cb13936 100644 --- a/twilio/rest/intelligence/v3/version.py +++ b/twilio/rest/intelligence/v3/version.py @@ -64,7 +64,7 @@ class OperatorVersionStatus(object): def __init__( self, version: Version, - payload: ResponseResource, + payload: Dict[str, Any], id: str, resource_version: Optional[int] = None, ): @@ -91,8 +91,8 @@ def __init__( self.description: Optional[str] = payload.get("description") self.author: Optional["VersionInstance.OperatorAuthor"] = payload.get("author") self.prompt: Optional[str] = payload.get("prompt") - self.output_format: Optional["VersionInstance.str"] = payload.get( - "outputFormat" + self.output_format: Optional["VersionInstance.OperatorOutputFormat"] = ( + payload.get("outputFormat") ) self.output_schema: Optional[Dict[str, object]] = payload.get("outputSchema") self.training_examples: Optional[List[str]] = payload.get("trainingExamples") diff --git a/twilio/rest/knowledge/v1/knowledge/__init__.py b/twilio/rest/knowledge/v1/knowledge/__init__.py index 55395f073..568850ebc 100644 --- a/twilio/rest/knowledge/v1/knowledge/__init__.py +++ b/twilio/rest/knowledge/v1/knowledge/__init__.py @@ -46,7 +46,13 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.policy: Optional[ KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest - ] = payload.get("policy") + ] = ( + KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") @@ -107,7 +113,13 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.policy: Optional[ KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest - ] = payload.get("policy") + ] = ( + KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") @@ -364,7 +376,13 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.policy: Optional[ KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest - ] = payload.get("policy") + ] = ( + KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") @@ -425,7 +443,13 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.policy: Optional[ KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest - ] = payload.get("policy") + ] = ( + KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") @@ -812,7 +836,13 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.policy: Optional[ KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest - ] = payload.get("policy") + ] = ( + KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") @@ -873,7 +903,13 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.policy: Optional[ KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest - ] = payload.get("policy") + ] = ( + KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) 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 dc40d54a9..1f5fedbe6 100644 --- a/twilio/rest/knowledge/v2/knowledge.py +++ b/twilio/rest/knowledge/v2/knowledge.py @@ -50,7 +50,7 @@ class SupportedFileMimeType(object): def __init__( self, version: Version, - payload: ResponseResource, + payload: Dict[str, Any], kb_id: str, knowledge_id: Optional[str] = None, ): @@ -60,7 +60,7 @@ def __init__( self.description: Optional[str] = payload.get("description") self.source: Optional[str] = payload.get("source") self.id: Optional[str] = payload.get("id") - self.status: Optional["KnowledgeInstance.str"] = payload.get("status") + self.status: Optional[str] = payload.get("status") self.created_at: Optional[datetime] = deserialize.iso8601_datetime( payload.get("createdAt") ) @@ -630,8 +630,10 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.description: Optional[str] = payload.get("description") - self.source: Optional[KnowledgeList.KnowledgeSourceTypes] = payload.get( - "source" + self.source: Optional[KnowledgeList.KnowledgeSourceTypes] = ( + KnowledgeList.KnowledgeSourceTypes(payload.get("source")) + if payload.get("source") is not None + else None ) def to_dict(self): @@ -641,6 +643,61 @@ def to_dict(self): "source": self.source.to_dict() if self.source is not None else None, } + class KnowledgeErrorGroup(object): + """ + :ivar title: The error type or reason (e.g., \"404 Not Found\", \"500 Internal Server Error\"). + :ivar instances: Array of error instances for this error title. Required when an error group is present. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.title: Optional[str] = payload.get("title") + self.instances: Optional[List[KnowledgeList.KnowledgeErrorInstance]] = ( + [ + ( + KnowledgeList.KnowledgeErrorInstance(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("instances") + ] + if payload.get("instances") is not None + else None + ) + + def to_dict(self): + return { + "title": self.title, + "instances": ( + [instances.to_dict() for instances in self.instances] + if self.instances is not None + else None + ), + } + + class KnowledgeErrorInstance(object): + """ + :ivar type: A URI reference identifying the problem type, resolving to human-readable documentation (e.g., https://www.twilio.com/docs/api/errors/420018). + :ivar code: Twilio-specific numeric error code for programmatic handling. + :ivar instance: The specific URL or resource that caused the error. + :ivar detail: Detailed explanation of the error. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.type: Optional[str] = payload.get("type") + self.code: Optional[int] = payload.get("code") + self.instance: Optional[str] = payload.get("instance") + self.detail: Optional[str] = payload.get("detail") + + def to_dict(self): + return { + "type": self.type, + "code": self.code, + "instance": self.instance, + "detail": self.detail, + } + class KnowledgeSourceTypes(object): """ :ivar type: Raw text knowledge sources @@ -648,6 +705,7 @@ class KnowledgeSourceTypes(object): :ivar url: The URL to crawl for web content :ivar crawl_depth: The maximum depth to crawl from the source URL :ivar crawl_period: Frequency of re-crawling the website for updated content + :ivar errors: Processing errors encountered during web crawling, grouped by title. Array of error groups, where each group has a title and list of error instances. Only present when crawl errors occurred. :ivar file_name: Name of the file to be uploaded :ivar file_size: Expected size of the file in bytes :ivar mime_type: @@ -657,12 +715,22 @@ class KnowledgeSourceTypes(object): def __init__(self, payload: Dict[str, Any]): - self.type: Optional["KnowledgeInstance.str"] = payload.get("type") + self.type: Optional[str] = payload.get("type") self.content: Optional[str] = payload.get("content") self.url: Optional[str] = payload.get("url") self.crawl_depth: Optional[int] = payload.get("crawlDepth") - self.crawl_period: Optional["KnowledgeInstance.str"] = payload.get( - "crawlPeriod" + self.crawl_period: Optional[str] = payload.get("crawlPeriod") + self.errors: Optional[List[KnowledgeList.KnowledgeErrorGroup]] = ( + [ + ( + KnowledgeList.KnowledgeErrorGroup(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("errors") + ] + if payload.get("errors") is not None + else None ) self.file_name: Optional[str] = payload.get("fileName") self.file_size: Optional[int] = payload.get("fileSize") @@ -679,6 +747,11 @@ def to_dict(self): "url": self.url, "crawlDepth": self.crawl_depth, "crawlPeriod": self.crawl_period, + "errors": ( + [errors.to_dict() for errors in self.errors] + if self.errors is not None + else None + ), "fileName": self.file_name, "fileSize": self.file_size, "mimeType": self.mime_type, diff --git a/twilio/rest/knowledge/v2/knowledge_basis.py b/twilio/rest/knowledge/v2/knowledge_basis.py index d4fa29ac7..a94a99e2a 100644 --- a/twilio/rest/knowledge/v2/knowledge_basis.py +++ b/twilio/rest/knowledge/v2/knowledge_basis.py @@ -39,14 +39,14 @@ class KnowledgeBasisInstance(InstanceResource): """ def __init__( - self, version: Version, payload: ResponseResource, kb_id: Optional[str] = None + self, version: Version, payload: Dict[str, Any], kb_id: Optional[str] = None ): super().__init__(version) self.display_name: Optional[str] = payload.get("displayName") self.description: Optional[str] = payload.get("description") self.id: Optional[str] = payload.get("id") - self.status: Optional["KnowledgeBasisInstance.str"] = payload.get("status") + self.status: Optional[str] = payload.get("status") self.created_at: Optional[datetime] = deserialize.iso8601_datetime( payload.get("createdAt") ) diff --git a/twilio/rest/knowledge/v2/operation.py b/twilio/rest/knowledge/v2/operation.py index e967c1d8b..41e8b0dca 100644 --- a/twilio/rest/knowledge/v2/operation.py +++ b/twilio/rest/knowledge/v2/operation.py @@ -45,7 +45,7 @@ def __init__( super().__init__(version) self.operation_id: Optional[str] = payload.get("operationId") - self.status: Optional["OperationInstance.str"] = payload.get("status") + self.status: Optional[str] = payload.get("status") self.created_at: Optional[datetime] = deserialize.iso8601_datetime( payload.get("createdAt") ) diff --git a/twilio/rest/lookups/v2/lookup_override.py b/twilio/rest/lookups/v2/lookup_override.py index ea3cd6b38..e33110cb4 100644 --- a/twilio/rest/lookups/v2/lookup_override.py +++ b/twilio/rest/lookups/v2/lookup_override.py @@ -32,9 +32,7 @@ class OverridesRequest(object): def __init__(self, payload: Dict[str, Any]): - self.line_type: Optional["LookupOverrideInstance.str"] = payload.get( - "line_type" - ) + self.line_type: Optional[str] = payload.get("line_type") self.reason: Optional[str] = payload.get("reason") def to_dict(self): @@ -71,12 +69,8 @@ def __init__( super().__init__(version) self.phone_number: Optional[str] = payload.get("phone_number") - self.original_line_type: Optional["LookupOverrideInstance.str"] = payload.get( - "original_line_type" - ) - self.overridden_line_type: Optional["LookupOverrideInstance.str"] = payload.get( - "overridden_line_type" - ) + self.original_line_type: Optional[str] = payload.get("original_line_type") + self.overridden_line_type: Optional[str] = payload.get("overridden_line_type") self.override_reason: Optional[str] = payload.get("override_reason") self.override_timestamp: Optional[datetime] = deserialize.iso8601_datetime( payload.get("override_timestamp") @@ -321,9 +315,7 @@ class OverridesRequest(object): def __init__(self, payload: Dict[str, Any]): - self.line_type: Optional["LookupOverrideInstance.str"] = payload.get( - "line_type" - ) + self.line_type: Optional[str] = payload.get("line_type") self.reason: Optional[str] = payload.get("reason") def to_dict(self): @@ -777,9 +769,7 @@ class OverridesRequest(object): def __init__(self, payload: Dict[str, Any]): - self.line_type: Optional["LookupOverrideInstance.str"] = payload.get( - "line_type" - ) + self.line_type: Optional[str] = payload.get("line_type") self.reason: Optional[str] = payload.get("reason") def to_dict(self): diff --git a/twilio/rest/lookups/v2/phone_number.py b/twilio/rest/lookups/v2/phone_number.py index 224035172..867cb7380 100644 --- a/twilio/rest/lookups/v2/phone_number.py +++ b/twilio/rest/lookups/v2/phone_number.py @@ -64,9 +64,9 @@ def __init__( self.phone_number: Optional[str] = payload.get("phone_number") self.national_format: Optional[str] = payload.get("national_format") self.valid: Optional[bool] = payload.get("valid") - self.validation_errors: Optional[List[Enumstr]] = payload.get( - "validation_errors" - ) + self.validation_errors: Optional[ + List["PhoneNumberInstance.ValidationError"] + ] = payload.get("validation_errors") self.caller_name: Optional[str] = payload.get("caller_name") self.sim_swap: Optional[str] = payload.get("sim_swap") self.call_forwarding: Optional[str] = payload.get("call_forwarding") diff --git a/twilio/rest/lookups/v2/query.py b/twilio/rest/lookups/v2/query.py index 1bb3ff6cc..c421107cc 100644 --- a/twilio/rest/lookups/v2/query.py +++ b/twilio/rest/lookups/v2/query.py @@ -104,16 +104,22 @@ def __init__(self, payload: Dict[str, Any]): self.correlation_id: Optional[str] = payload.get("correlation_id") self.phone_number: Optional[str] = payload.get("phone_number") - self.fields: Optional[List[Enumstr]] = payload.get("fields") + self.fields: Optional[List[str]] = payload.get("fields") self.country_code: Optional[str] = payload.get("country_code") self.identity_match: Optional[QueryList.IdentityMatchParameters] = ( - payload.get("identity_match") + QueryList.IdentityMatchParameters(payload.get("identity_match")) + if payload.get("identity_match") is not None + else None ) self.reassigned_number: Optional[QueryList.ReassignedNumberParameters] = ( - payload.get("reassigned_number") + QueryList.ReassignedNumberParameters(payload.get("reassigned_number")) + if payload.get("reassigned_number") is not None + else None ) - self.sms_pumping_risk: Optional[QueryList.RiskParameters] = payload.get( - "sms_pumping_risk" + 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 ) def to_dict(self): @@ -147,7 +153,16 @@ class LookupRequest(object): def __init__(self, payload: Dict[str, Any]): self.phone_numbers: Optional[List[QueryList.LookupBatchRequest]] = ( - payload.get("phone_numbers") + [ + ( + QueryList.LookupBatchRequest(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("phone_numbers") + ] + if payload.get("phone_numbers") is not None + else None ) def to_dict(self): @@ -288,16 +303,22 @@ def __init__(self, payload: Dict[str, Any]): self.correlation_id: Optional[str] = payload.get("correlation_id") self.phone_number: Optional[str] = payload.get("phone_number") - self.fields: Optional[List[Enumstr]] = payload.get("fields") + self.fields: Optional[List[str]] = payload.get("fields") self.country_code: Optional[str] = payload.get("country_code") self.identity_match: Optional[QueryList.IdentityMatchParameters] = ( - payload.get("identity_match") + QueryList.IdentityMatchParameters(payload.get("identity_match")) + if payload.get("identity_match") is not None + else None ) self.reassigned_number: Optional[QueryList.ReassignedNumberParameters] = ( - payload.get("reassigned_number") + QueryList.ReassignedNumberParameters(payload.get("reassigned_number")) + if payload.get("reassigned_number") is not None + else None ) - self.sms_pumping_risk: Optional[QueryList.RiskParameters] = payload.get( - "sms_pumping_risk" + 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 ) def to_dict(self): @@ -331,7 +352,16 @@ class LookupRequest(object): def __init__(self, payload: Dict[str, Any]): self.phone_numbers: Optional[List[QueryList.LookupBatchRequest]] = ( - payload.get("phone_numbers") + [ + ( + QueryList.LookupBatchRequest(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("phone_numbers") + ] + if payload.get("phone_numbers") is not None + else None ) def to_dict(self): diff --git a/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_usage.py b/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_usage.py index 9a2a66844..cf615ac8d 100644 --- a/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_usage.py +++ b/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_usage.py @@ -38,7 +38,20 @@ def __init__(self, payload: Dict[str, Any]): List[ InstalledAddOnUsageList.MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems ] - ] = payload.get("billable_items") + ] = ( + [ + ( + InstalledAddOnUsageList.MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("billable_items") + ] + if payload.get("billable_items") is not None + else None + ) def to_dict(self): return { @@ -83,9 +96,11 @@ def __init__( self.total_submitted: Optional[float] = deserialize.decimal( payload.get("total_submitted") ) - self.billable_items: Optional[List[InstalledAddOnUsageList.str]] = payload.get( - "billable_items" - ) + self.billable_items: Optional[ + List[ + InstalledAddOnUsageList.MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems + ] + ] = payload.get("billable_items") self._solution = { "installed_add_on_sid": installed_add_on_sid, @@ -118,7 +133,20 @@ def __init__(self, payload: Dict[str, Any]): List[ InstalledAddOnUsageList.MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems ] - ] = payload.get("billable_items") + ] = ( + [ + ( + InstalledAddOnUsageList.MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("billable_items") + ] + if payload.get("billable_items") is not None + else None + ) def to_dict(self): return { diff --git a/twilio/rest/marketplace/v1/module_data_management.py b/twilio/rest/marketplace/v1/module_data_management.py index 6ac9e02d4..56ab7fa87 100644 --- a/twilio/rest/marketplace/v1/module_data_management.py +++ b/twilio/rest/marketplace/v1/module_data_management.py @@ -49,7 +49,9 @@ def __init__( self.documentation: Optional[Dict[str, object]] = payload.get("documentation") self.configuration: Optional[Dict[str, object]] = payload.get("configuration") self.pricing: Optional[Dict[str, object]] = payload.get("pricing") - self.listings: Optional[List[Dict[str, object]]] = payload.get("listings") + self.listings: Optional[List[Dict[str, Dict[str, Dict[str, object]]]]] = ( + payload.get("listings") + ) self._solution = { "sid": sid or self.sid, diff --git a/twilio/rest/memory/v1/bulk.py b/twilio/rest/memory/v1/bulk.py index eb7794584..fe7ba5caa 100644 --- a/twilio/rest/memory/v1/bulk.py +++ b/twilio/rest/memory/v1/bulk.py @@ -58,7 +58,9 @@ class ProfileData(object): def __init__(self, payload: Dict[str, Any]): - self.traits: Optional[Dict[str, Dict[str, object]]] = payload.get("traits") + self.traits: Optional[Dict[str, Dict[str, Dict[str, object]]]] = ( + payload.get("traits") + ) def to_dict(self): return { @@ -72,8 +74,13 @@ class UpdateProfilesBulkRequest(object): def __init__(self, payload: Dict[str, Any]): - self.profiles: Optional[List[BulkList.ProfileData]] = payload.get( - "profiles" + self.profiles: Optional[List[BulkList.ProfileData]] = ( + [ + BulkList.ProfileData(item) if isinstance(item, dict) else item + for item in payload.get("profiles") + ] + if payload.get("profiles") is not None + else None ) def to_dict(self): diff --git a/twilio/rest/memory/v1/conversation_summary.py b/twilio/rest/memory/v1/conversation_summary.py index 7f95b1beb..a53ba66c0 100644 --- a/twilio/rest/memory/v1/conversation_summary.py +++ b/twilio/rest/memory/v1/conversation_summary.py @@ -40,7 +40,7 @@ class ConversationSummaryInstance(InstanceResource): def __init__( self, version: Version, - payload: ResponseResource, + payload: Dict[str, Any], store_id: str, profile_id: str, summary_id: Optional[str] = None, @@ -557,7 +557,16 @@ class CreateSummariesRequest(object): def __init__(self, payload: Dict[str, Any]): self.summaries: Optional[List[ConversationSummaryList.SummaryCore]] = ( - payload.get("summaries") + [ + ( + ConversationSummaryList.SummaryCore(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("summaries") + ] + if payload.get("summaries") is not None + else None ) def to_dict(self): diff --git a/twilio/rest/memory/v1/data_mapping.py b/twilio/rest/memory/v1/data_mapping.py index 8cefd6789..0e96d2732 100644 --- a/twilio/rest/memory/v1/data_mapping.py +++ b/twilio/rest/memory/v1/data_mapping.py @@ -28,8 +28,9 @@ class DataMappingInstance(InstanceResource): class DataMappingType(object): - CSV = "CSV" - DATASET = "DATASET" + INGRESS = "INGRESS" + DATASET_CLOUDAPP = "DATASET_CLOUDAPP" + DATASET_WAREHOUSE = "DATASET_WAREHOUSE" """ :ivar message: @@ -48,7 +49,7 @@ class DataMappingType(object): def __init__( self, version: Version, - payload: ResponseResource, + payload: Dict[str, Any], store_id: str, data_mapping_id: Optional[str] = None, ): @@ -601,10 +602,14 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.is_enabled: Optional[bool] = payload.get("isEnabled") self.mapping_to: Optional[DataMappingList.DataMappingToTraits] = ( - payload.get("mappingTo") + DataMappingList.DataMappingToTraits(payload.get("mappingTo")) + if payload.get("mappingTo") is not None + else None ) self.mapping_from: Optional[DataMappingList.DataMappingFromTypes] = ( - payload.get("mappingFrom") + DataMappingList.DataMappingFromTypes(payload.get("mappingFrom")) + if payload.get("mappingFrom") is not None + else None ) def to_dict(self): @@ -636,7 +641,9 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.is_enabled: Optional[bool] = payload.get("isEnabled") self.mapping_to: Optional[DataMappingList.DataMappingToTraits] = ( - payload.get("mappingTo") + DataMappingList.DataMappingToTraits(payload.get("mappingTo")) + if payload.get("mappingTo") is not None + else None ) def to_dict(self): @@ -652,13 +659,13 @@ def to_dict(self): class DataMappingFromTypes(object): """ :ivar type: The source data type, which determines the source of the data and the required configuration parameters. - :ivar columns: The list of CSV column names that serve as the source fields. + :ivar columns: The list of ingress column names that serve as the source fields. :ivar dataset_id: The unique identifier of the TDI dataset to connect. """ def __init__(self, payload: Dict[str, Any]): - self.type: Optional["DataMappingInstance.str"] = payload.get("type") + self.type: Optional[str] = payload.get("type") self.columns: Optional[List[str]] = payload.get("columns") self.dataset_id: Optional[str] = payload.get("datasetId") @@ -677,9 +684,18 @@ class DataMappingToTraits(object): def __init__(self, payload: Dict[str, Any]): - self.type: Optional["DataMappingInstance.str"] = payload.get("type") + self.type: Optional[str] = payload.get("type") self.mappings: Optional[List[DataMappingList.MappingTraitItem]] = ( - payload.get("mappings") + [ + ( + DataMappingList.MappingTraitItem(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("mappings") + ] + if payload.get("mappings") is not None + else None ) def to_dict(self): diff --git a/twilio/rest/memory/v1/identifier.py b/twilio/rest/memory/v1/identifier.py index b6579a322..ee327d866 100644 --- a/twilio/rest/memory/v1/identifier.py +++ b/twilio/rest/memory/v1/identifier.py @@ -34,7 +34,7 @@ class IdentifierInstance(InstanceResource): def __init__( self, version: Version, - payload: ResponseResource, + payload: Dict[str, Any], store_id: str, profile_id: str, id_type: Optional[str] = None, diff --git a/twilio/rest/memory/v1/identity_resolution_setting.py b/twilio/rest/memory/v1/identity_resolution_setting.py index 6c1ea4439..af4c21f95 100644 --- a/twilio/rest/memory/v1/identity_resolution_setting.py +++ b/twilio/rest/memory/v1/identity_resolution_setting.py @@ -32,7 +32,7 @@ class IdentityResolutionSettingInstance(InstanceResource): :ivar status_url: URI to check operation status. """ - def __init__(self, version: Version, payload: ResponseResource, store_id: str): + def __init__(self, version: Version, payload: Dict[str, Any], store_id: str): super().__init__(version) self.identifier_configs: Optional[List[str]] = payload.get("identifierConfigs") @@ -73,18 +73,12 @@ class IdentifierConfig(object): def __init__(self, payload: Dict[str, Any]): self.id_type: Optional[str] = payload.get("idType") - self.matching_algo: Optional["IdentityResolutionSettingInstance.str"] = ( - payload.get("matchingAlgo") - ) + self.matching_algo: Optional[str] = payload.get("matchingAlgo") self.matching_threshold: Optional[int] = payload.get("matchingThreshold") self.limit: Optional[int] = payload.get("limit") - self.limit_policy: Optional["IdentityResolutionSettingInstance.str"] = ( - payload.get("limitPolicy") - ) + self.limit_policy: Optional[str] = payload.get("limitPolicy") self.enforce_unique: Optional[bool] = payload.get("enforceUnique") - self.normalization: Optional["IdentityResolutionSettingInstance.str"] = ( - payload.get("normalization") - ) + self.normalization: Optional[str] = payload.get("normalization") def to_dict(self): return { @@ -107,7 +101,18 @@ def __init__(self, payload: Dict[str, Any]): self.identifier_configs: Optional[ List[IdentityResolutionSettingList.IdentifierConfig] - ] = payload.get("identifierConfigs") + ] = ( + [ + ( + IdentityResolutionSettingList.IdentifierConfig(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("identifierConfigs") + ] + if payload.get("identifierConfigs") is not None + else None + ) self.matching_rules: Optional[List[str]] = payload.get("matchingRules") def to_dict(self): diff --git a/twilio/rest/memory/v1/import_.py b/twilio/rest/memory/v1/import_.py index 3c30af4c5..eda0ec92a 100644 --- a/twilio/rest/memory/v1/import_.py +++ b/twilio/rest/memory/v1/import_.py @@ -43,13 +43,13 @@ class ImportInstance(InstanceResource): def __init__( self, version: Version, - payload: ResponseResource, + payload: Dict[str, Any], store_id: str, import_id: Optional[str] = None, ): super().__init__(version) - self.status: Optional["ImportInstance.str"] = payload.get("status") + self.status: Optional[str] = payload.get("status") self.filename: Optional[str] = payload.get("filename") self.created_at: Optional[datetime] = deserialize.iso8601_datetime( payload.get("createdAt") @@ -319,7 +319,16 @@ def __init__(self, payload: Dict[str, Any]): self.filename: Optional[str] = payload.get("filename") self.file_size: Optional[int] = payload.get("fileSize") self.column_mappings: Optional[List[ImportList.ColumnMappingItem]] = ( - payload.get("columnMappings") + [ + ( + ImportList.ColumnMappingItem(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("columnMappings") + ] + if payload.get("columnMappings") is not None + else None ) def to_dict(self): diff --git a/twilio/rest/memory/v1/observation.py b/twilio/rest/memory/v1/observation.py index 3f61682c7..c24f89897 100644 --- a/twilio/rest/memory/v1/observation.py +++ b/twilio/rest/memory/v1/observation.py @@ -40,7 +40,7 @@ class ObservationInstance(InstanceResource): def __init__( self, version: Version, - payload: ResponseResource, + payload: Dict[str, Any], store_id: str, profile_id: str, observation_id: Optional[str] = None, @@ -552,7 +552,18 @@ def __init__(self, payload: Dict[str, Any]): self.observations: Optional[ List[ObservationList.ObservationCreateRequest] - ] = payload.get("observations") + ] = ( + [ + ( + ObservationList.ObservationCreateRequest(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("observations") + ] + if payload.get("observations") is not None + else None + ) def to_dict(self): return { diff --git a/twilio/rest/memory/v1/operation.py b/twilio/rest/memory/v1/operation.py index 7c0c5aa8e..f93e3a920 100644 --- a/twilio/rest/memory/v1/operation.py +++ b/twilio/rest/memory/v1/operation.py @@ -45,7 +45,7 @@ def __init__( super().__init__(version) self.operation_id: Optional[str] = payload.get("operationId") - self.status: Optional["OperationInstance.str"] = payload.get("status") + self.status: Optional[str] = payload.get("status") self.created_at: Optional[datetime] = deserialize.iso8601_datetime( payload.get("createdAt") ) diff --git a/twilio/rest/memory/v1/profile.py b/twilio/rest/memory/v1/profile.py index de1016ce6..b6f6b883d 100644 --- a/twilio/rest/memory/v1/profile.py +++ b/twilio/rest/memory/v1/profile.py @@ -38,7 +38,7 @@ class ProfileInstance(InstanceResource): def __init__( self, version: Version, - payload: ResponseResource, + payload: Dict[str, Any], store_id: str, profile_id: Optional[str] = None, ): @@ -51,7 +51,9 @@ def __init__( self.created_at: Optional[datetime] = deserialize.iso8601_datetime( payload.get("createdAt") ) - self.traits: Optional[Dict[str, Dict[str, object]]] = payload.get("traits") + self.traits: Optional[Dict[str, Dict[str, Dict[str, object]]]] = payload.get( + "traits" + ) # Only set _solution if path params are provided (not None) if store_id is not None or profile_id is not None: @@ -585,7 +587,9 @@ class ProfileData(object): def __init__(self, payload: Dict[str, Any]): - self.traits: Optional[Dict[str, Dict[str, object]]] = payload.get("traits") + self.traits: Optional[ + Dict[str, Dict[str, Dict[str, Dict[str, Dict[str, Dict[str, object]]]]]] + ] = payload.get("traits") def to_dict(self): return { @@ -599,7 +603,9 @@ class ProfilePatch(object): def __init__(self, payload: Dict[str, Any]): - self.traits: Optional[Dict[str, Dict[str, object]]] = payload.get("traits") + self.traits: Optional[ + Dict[str, Dict[str, Dict[str, Dict[str, Dict[str, object]]]]] + ] = payload.get("traits") def to_dict(self): return { diff --git a/twilio/rest/memory/v1/recall.py b/twilio/rest/memory/v1/recall.py index ff759be74..d04f56a39 100644 --- a/twilio/rest/memory/v1/recall.py +++ b/twilio/rest/memory/v1/recall.py @@ -98,7 +98,11 @@ def __init__(self, payload: Dict[str, Any]): self.id: Optional[str] = payload.get("id") self.name: Optional[str] = payload.get("name") - self.type: Optional[ParticipantType] = payload.get("type") + self.type: Optional[ParticipantType] = ( + ParticipantType(payload.get("type")) + if payload.get("type") is not None + else None + ) self.profile_id: Optional[str] = payload.get("profileId") self.address: Optional[str] = payload.get("address") self.channel: Optional[str] = payload.get("channel") @@ -168,7 +172,11 @@ def __init__(self, payload: Dict[str, Any]): self.id: Optional[str] = payload.get("id") self.name: Optional[str] = payload.get("name") - self.type: Optional[ParticipantType] = payload.get("type") + self.type: Optional[ParticipantType] = ( + ParticipantType(payload.get("type")) + if payload.get("type") is not None + else None + ) self.profile_id: Optional[str] = payload.get("profileId") self.address: Optional[str] = payload.get("address") self.channel: Optional[str] = payload.get("channel") diff --git a/twilio/rest/memory/v1/store.py b/twilio/rest/memory/v1/store.py index 2821e4992..4364dbde2 100644 --- a/twilio/rest/memory/v1/store.py +++ b/twilio/rest/memory/v1/store.py @@ -39,10 +39,7 @@ class StoreInstance(InstanceResource): """ def __init__( - self, - version: Version, - payload: ResponseResource, - store_id: Optional[str] = None, + self, version: Version, payload: Dict[str, Any], store_id: Optional[str] = None ): super().__init__(version) @@ -53,7 +50,7 @@ def __init__( self.display_name: Optional[str] = payload.get("displayName") self.description: Optional[str] = payload.get("description") self.id: Optional[str] = payload.get("id") - self.status: Optional["StoreInstance.str"] = payload.get("status") + self.status: Optional[str] = payload.get("status") self.intelligence_service_id: Optional[str] = payload.get( "intelligenceServiceId" ) diff --git a/twilio/rest/memory/v1/trait_group.py b/twilio/rest/memory/v1/trait_group.py index 1412ffc70..774ca5694 100644 --- a/twilio/rest/memory/v1/trait_group.py +++ b/twilio/rest/memory/v1/trait_group.py @@ -39,7 +39,7 @@ class TraitGroupInstance(InstanceResource): def __init__( self, version: Version, - payload: ResponseResource, + payload: Dict[str, Any], store_id: str, trait_group_name: Optional[str] = None, ): @@ -752,7 +752,14 @@ class PatchTraitGroupRequest(object): def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") - self.traits: Optional[Dict[str, TraitDefinition]] = payload.get("traits") + self.traits: Optional[Dict[str, TraitGroupList.TraitDefinition]] = ( + { + k: TraitGroupList.TraitDefinition(v) if isinstance(v, dict) else v + for k, v in payload.get("traits").items() + } + if payload.get("traits") is not None + else None + ) def to_dict(self): return { @@ -776,8 +783,10 @@ def __init__(self, payload: Dict[str, Any]): self.data_type: Optional[str] = payload.get("dataType") self.description: Optional[str] = payload.get("description") - self.validation_rule: Optional[ValidationRule] = payload.get( - "validationRule" + self.validation_rule: Optional[TraitGroupList.ValidationRule] = ( + TraitGroupList.ValidationRule(payload.get("validationRule")) + if payload.get("validationRule") is not None + else None ) self.id_type_promotion: Optional[str] = payload.get("idTypePromotion") @@ -805,8 +814,13 @@ def __init__(self, payload: Dict[str, Any]): self.display_name: Optional[str] = payload.get("displayName") self.description: Optional[str] = payload.get("description") - self.traits: Optional[Dict[str, TraitGroupCoreTraits]] = payload.get( - "traits" + self.traits: Optional[Dict[str, TraitGroupCoreTraits]] = ( + { + k: TraitGroupCoreTraits(v) if isinstance(v, dict) else v + for k, v in payload.get("traits").items() + } + if payload.get("traits") is not None + else None ) self.version: Optional[int] = deserialize.integer(payload.get("version")) @@ -834,8 +848,10 @@ def __init__(self, payload: Dict[str, Any]): self.data_type: Optional[str] = payload.get("dataType") self.description: Optional[str] = payload.get("description") - self.validation_rule: Optional[ValidationRule] = payload.get( - "validationRule" + self.validation_rule: Optional[ValidationRule] = ( + ValidationRule(payload.get("validationRule")) + if payload.get("validationRule") is not None + else None ) self.id_type_promotion: Optional[str] = payload.get("idTypePromotion") @@ -862,8 +878,17 @@ def __init__(self, payload: Dict[str, Any]): self.display_name: Optional[str] = payload.get("displayName") self.description: Optional[str] = payload.get("description") - self.traits: Optional[Dict[str, TraitGroupRequestTraits]] = payload.get( - "traits" + self.traits: Optional[Dict[str, TraitGroupList.TraitGroupRequestTraits]] = ( + { + k: ( + TraitGroupList.TraitGroupRequestTraits(v) + if isinstance(v, dict) + else v + ) + for k, v in payload.get("traits").items() + } + if payload.get("traits") is not None + else None ) def to_dict(self): @@ -889,8 +914,10 @@ def __init__(self, payload: Dict[str, Any]): self.data_type: Optional[str] = payload.get("dataType") self.description: Optional[str] = payload.get("description") - self.validation_rule: Optional[ValidationRule] = payload.get( - "validationRule" + self.validation_rule: Optional[TraitGroupList.ValidationRule] = ( + TraitGroupList.ValidationRule(payload.get("validationRule")) + if payload.get("validationRule") is not None + else None ) self.id_type_promotion: Optional[str] = payload.get("idTypePromotion") diff --git a/twilio/rest/messaging/v1/brand_registration/__init__.py b/twilio/rest/messaging/v1/brand_registration/__init__.py index 349d7ba4f..fa3251135 100644 --- a/twilio/rest/messaging/v1/brand_registration/__init__.py +++ b/twilio/rest/messaging/v1/brand_registration/__init__.py @@ -100,7 +100,9 @@ def __init__( ) self.tcr_id: Optional[str] = payload.get("tcr_id") self.failure_reason: Optional[str] = payload.get("failure_reason") - self.errors: Optional[List[Dict[str, object]]] = payload.get("errors") + self.errors: Optional[ + List[Dict[str, Dict[str, Dict[str, Dict[str, object]]]]] + ] = payload.get("errors") self.url: Optional[str] = payload.get("url") self.brand_score: Optional[int] = deserialize.integer( payload.get("brand_score") diff --git a/twilio/rest/messaging/v1/service/us_app_to_person.py b/twilio/rest/messaging/v1/service/us_app_to_person.py index ba3bfdc12..09e2208ea 100644 --- a/twilio/rest/messaging/v1/service/us_app_to_person.py +++ b/twilio/rest/messaging/v1/service/us_app_to_person.py @@ -103,7 +103,9 @@ def __init__( ) self.url: Optional[str] = payload.get("url") self.mock: Optional[bool] = payload.get("mock") - self.errors: Optional[List[Dict[str, object]]] = payload.get("errors") + self.errors: Optional[ + List[Dict[str, Dict[str, Dict[str, Dict[str, object]]]]] + ] = payload.get("errors") self.privacy_policy_url: Optional[str] = payload.get("privacy_policy_url") self.terms_and_conditions_url: Optional[str] = payload.get( "terms_and_conditions_url" diff --git a/twilio/rest/messaging/v1/tollfree_verification.py b/twilio/rest/messaging/v1/tollfree_verification.py index 844e16054..d78bd79fc 100644 --- a/twilio/rest/messaging/v1/tollfree_verification.py +++ b/twilio/rest/messaging/v1/tollfree_verification.py @@ -169,8 +169,8 @@ def __init__( "business_contact_phone" ) self.notification_email: Optional[str] = payload.get("notification_email") - self.use_case_categories: Optional["TollfreeVerificationInstance.str]"] = ( - payload.get("use_case_categories") + self.use_case_categories: Optional[List[str]] = payload.get( + "use_case_categories" ) self.use_case_summary: Optional[str] = payload.get("use_case_summary") self.production_message_sample: Optional[str] = payload.get( @@ -224,9 +224,9 @@ def __init__( ) self.age_gated_content: Optional[bool] = payload.get("age_gated_content") self.opt_in_keywords: Optional[List[str]] = payload.get("opt_in_keywords") - self.rejection_reasons: Optional[List[Dict[str, object]]] = payload.get( - "rejection_reasons" - ) + self.rejection_reasons: Optional[ + List[Dict[str, Dict[str, Dict[str, Dict[str, object]]]]] + ] = payload.get("rejection_reasons") self.resource_links: Optional[Dict[str, object]] = payload.get("resource_links") self.external_reference_id: Optional[str] = payload.get("external_reference_id") self.vetting_id: Optional[str] = payload.get("vetting_id") diff --git a/twilio/rest/messaging/v2/channels_sender.py b/twilio/rest/messaging/v2/channels_sender.py index 603a4c7ed..23462b7d0 100644 --- a/twilio/rest/messaging/v2/channels_sender.py +++ b/twilio/rest/messaging/v2/channels_sender.py @@ -36,16 +36,12 @@ class MessagingV2ChannelsSenderConfiguration(object): def __init__(self, payload: Dict[str, Any]): self.waba_id: Optional[str] = payload.get("waba_id") - self.verification_method: Optional["ChannelsSenderInstance.str"] = ( - payload.get("verification_method") - ) + self.verification_method: Optional[str] = payload.get("verification_method") self.verification_code: Optional[str] = payload.get("verification_code") self.voice_application_sid: Optional[str] = payload.get( "voice_application_sid" ) - self.account_type: Optional["ChannelsSenderInstance.str"] = payload.get( - "account_type" - ) + self.account_type: Optional[str] = payload.get("account_type") def to_dict(self): return { @@ -87,9 +83,7 @@ def __init__(self, payload: Dict[str, Any]): "terms_of_service_url" ) self.accent_color: Optional[str] = payload.get("accent_color") - self.use_case: Optional["ChannelsSenderInstance.str"] = payload.get( - "use_case" - ) + self.use_case: Optional[str] = payload.get("use_case") self.vertical: Optional[str] = payload.get("vertical") self.websites: Optional[Dict[str, object]] = payload.get("websites") self.emails: Optional[Dict[str, object]] = payload.get("emails") @@ -181,13 +175,31 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.configuration: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderConfiguration - ] = payload.get("configuration") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook - ] = payload.get("webhook") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderWebhook( + payload.get("webhook") + ) + if payload.get("webhook") is not None + else None + ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile - ] = payload.get("profile") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderProfile( + payload.get("profile") + ) + if payload.get("profile") is not None + else None + ) def to_dict(self): return { @@ -215,13 +227,31 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.configuration: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderConfiguration - ] = payload.get("configuration") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook - ] = payload.get("webhook") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderWebhook( + payload.get("webhook") + ) + if payload.get("webhook") is not None + else None + ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile - ] = payload.get("profile") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderProfile( + payload.get("profile") + ) + if payload.get("profile") is not None + else None + ) def to_dict(self): return { @@ -248,13 +278,9 @@ class MessagingV2ChannelsSenderWebhook(object): def __init__(self, payload: Dict[str, Any]): self.callback_url: Optional[str] = payload.get("callback_url") - self.callback_method: Optional["ChannelsSenderInstance.str"] = payload.get( - "callback_method" - ) + self.callback_method: Optional[str] = payload.get("callback_method") self.fallback_url: Optional[str] = payload.get("fallback_url") - self.fallback_method: Optional["ChannelsSenderInstance.str"] = payload.get( - "fallback_method" - ) + self.fallback_method: Optional[str] = payload.get("fallback_method") self.status_callback_url: Optional[str] = payload.get("status_callback_url") self.status_callback_method: Optional[str] = payload.get( "status_callback_method" @@ -279,7 +305,11 @@ class MessagingV2RcsCarrier(object): def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") - self.status: Optional[MessagingV2RcsCarrierStatus] = payload.get("status") + self.status: Optional[MessagingV2RcsCarrierStatus] = ( + MessagingV2RcsCarrierStatus(payload.get("status")) + if payload.get("status") is not None + else None + ) def to_dict(self): return { @@ -299,9 +329,18 @@ def __init__(self, payload: Dict[str, Any]): self.country: Optional[str] = payload.get("country") self.registration_sid: Optional[str] = payload.get("registration_sid") - self.status: Optional[MessagingV2RcsCountryStatus] = payload.get("status") - self.carriers: Optional[List[MessagingV2RcsCarrier]] = payload.get( - "carriers" + self.status: Optional[MessagingV2RcsCountryStatus] = ( + MessagingV2RcsCountryStatus(payload.get("status")) + if payload.get("status") is not None + else None + ) + self.carriers: Optional[List[MessagingV2RcsCarrier]] = ( + [ + MessagingV2RcsCarrier(item) if isinstance(item, dict) else item + for item in payload.get("carriers") + ] + if payload.get("carriers") is not None + else None ) def to_dict(self): @@ -557,16 +596,12 @@ class MessagingV2ChannelsSenderConfiguration(object): def __init__(self, payload: Dict[str, Any]): self.waba_id: Optional[str] = payload.get("waba_id") - self.verification_method: Optional["ChannelsSenderInstance.str"] = ( - payload.get("verification_method") - ) + self.verification_method: Optional[str] = payload.get("verification_method") self.verification_code: Optional[str] = payload.get("verification_code") self.voice_application_sid: Optional[str] = payload.get( "voice_application_sid" ) - self.account_type: Optional["ChannelsSenderInstance.str"] = payload.get( - "account_type" - ) + self.account_type: Optional[str] = payload.get("account_type") def to_dict(self): return { @@ -608,9 +643,7 @@ def __init__(self, payload: Dict[str, Any]): "terms_of_service_url" ) self.accent_color: Optional[str] = payload.get("accent_color") - self.use_case: Optional["ChannelsSenderInstance.str"] = payload.get( - "use_case" - ) + self.use_case: Optional[str] = payload.get("use_case") self.vertical: Optional[str] = payload.get("vertical") self.websites: Optional[Dict[str, object]] = payload.get("websites") self.emails: Optional[Dict[str, object]] = payload.get("emails") @@ -702,13 +735,31 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.configuration: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderConfiguration - ] = payload.get("configuration") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook - ] = payload.get("webhook") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderWebhook( + payload.get("webhook") + ) + if payload.get("webhook") is not None + else None + ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile - ] = payload.get("profile") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderProfile( + payload.get("profile") + ) + if payload.get("profile") is not None + else None + ) def to_dict(self): return { @@ -736,13 +787,31 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.configuration: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderConfiguration - ] = payload.get("configuration") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook - ] = payload.get("webhook") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderWebhook( + payload.get("webhook") + ) + if payload.get("webhook") is not None + else None + ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile - ] = payload.get("profile") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderProfile( + payload.get("profile") + ) + if payload.get("profile") is not None + else None + ) def to_dict(self): return { @@ -769,13 +838,9 @@ class MessagingV2ChannelsSenderWebhook(object): def __init__(self, payload: Dict[str, Any]): self.callback_url: Optional[str] = payload.get("callback_url") - self.callback_method: Optional["ChannelsSenderInstance.str"] = payload.get( - "callback_method" - ) + self.callback_method: Optional[str] = payload.get("callback_method") self.fallback_url: Optional[str] = payload.get("fallback_url") - self.fallback_method: Optional["ChannelsSenderInstance.str"] = payload.get( - "fallback_method" - ) + self.fallback_method: Optional[str] = payload.get("fallback_method") self.status_callback_url: Optional[str] = payload.get("status_callback_url") self.status_callback_method: Optional[str] = payload.get( "status_callback_method" @@ -800,7 +865,11 @@ class MessagingV2RcsCarrier(object): def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") - self.status: Optional[MessagingV2RcsCarrierStatus] = payload.get("status") + self.status: Optional[MessagingV2RcsCarrierStatus] = ( + MessagingV2RcsCarrierStatus(payload.get("status")) + if payload.get("status") is not None + else None + ) def to_dict(self): return { @@ -820,9 +889,18 @@ def __init__(self, payload: Dict[str, Any]): self.country: Optional[str] = payload.get("country") self.registration_sid: Optional[str] = payload.get("registration_sid") - self.status: Optional[MessagingV2RcsCountryStatus] = payload.get("status") - self.carriers: Optional[List[MessagingV2RcsCarrier]] = payload.get( - "carriers" + self.status: Optional[MessagingV2RcsCountryStatus] = ( + MessagingV2RcsCountryStatus(payload.get("status")) + if payload.get("status") is not None + else None + ) + self.carriers: Optional[List[MessagingV2RcsCarrier]] = ( + [ + MessagingV2RcsCarrier(item) if isinstance(item, dict) else item + for item in payload.get("carriers") + ] + if payload.get("carriers") is not None + else None ) def to_dict(self): @@ -1180,16 +1258,12 @@ class MessagingV2ChannelsSenderConfiguration(object): def __init__(self, payload: Dict[str, Any]): self.waba_id: Optional[str] = payload.get("waba_id") - self.verification_method: Optional["ChannelsSenderInstance.str"] = ( - payload.get("verification_method") - ) + self.verification_method: Optional[str] = payload.get("verification_method") self.verification_code: Optional[str] = payload.get("verification_code") self.voice_application_sid: Optional[str] = payload.get( "voice_application_sid" ) - self.account_type: Optional["ChannelsSenderInstance.str"] = payload.get( - "account_type" - ) + self.account_type: Optional[str] = payload.get("account_type") def to_dict(self): return { @@ -1231,9 +1305,7 @@ def __init__(self, payload: Dict[str, Any]): "terms_of_service_url" ) self.accent_color: Optional[str] = payload.get("accent_color") - self.use_case: Optional["ChannelsSenderInstance.str"] = payload.get( - "use_case" - ) + self.use_case: Optional[str] = payload.get("use_case") self.vertical: Optional[str] = payload.get("vertical") self.websites: Optional[Dict[str, object]] = payload.get("websites") self.emails: Optional[Dict[str, object]] = payload.get("emails") @@ -1325,13 +1397,31 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.configuration: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderConfiguration - ] = payload.get("configuration") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook - ] = payload.get("webhook") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderWebhook( + payload.get("webhook") + ) + if payload.get("webhook") is not None + else None + ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile - ] = payload.get("profile") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderProfile( + payload.get("profile") + ) + if payload.get("profile") is not None + else None + ) def to_dict(self): return { @@ -1359,13 +1449,31 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.configuration: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderConfiguration - ] = payload.get("configuration") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook - ] = payload.get("webhook") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderWebhook( + payload.get("webhook") + ) + if payload.get("webhook") is not None + else None + ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile - ] = payload.get("profile") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderProfile( + payload.get("profile") + ) + if payload.get("profile") is not None + else None + ) def to_dict(self): return { @@ -1392,13 +1500,9 @@ class MessagingV2ChannelsSenderWebhook(object): def __init__(self, payload: Dict[str, Any]): self.callback_url: Optional[str] = payload.get("callback_url") - self.callback_method: Optional["ChannelsSenderInstance.str"] = payload.get( - "callback_method" - ) + self.callback_method: Optional[str] = payload.get("callback_method") self.fallback_url: Optional[str] = payload.get("fallback_url") - self.fallback_method: Optional["ChannelsSenderInstance.str"] = payload.get( - "fallback_method" - ) + self.fallback_method: Optional[str] = payload.get("fallback_method") self.status_callback_url: Optional[str] = payload.get("status_callback_url") self.status_callback_method: Optional[str] = payload.get( "status_callback_method" @@ -1423,7 +1527,11 @@ class MessagingV2RcsCarrier(object): def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") - self.status: Optional[MessagingV2RcsCarrierStatus] = payload.get("status") + self.status: Optional[MessagingV2RcsCarrierStatus] = ( + MessagingV2RcsCarrierStatus(payload.get("status")) + if payload.get("status") is not None + else None + ) def to_dict(self): return { @@ -1443,9 +1551,18 @@ def __init__(self, payload: Dict[str, Any]): self.country: Optional[str] = payload.get("country") self.registration_sid: Optional[str] = payload.get("registration_sid") - self.status: Optional[MessagingV2RcsCountryStatus] = payload.get("status") - self.carriers: Optional[List[MessagingV2RcsCarrier]] = payload.get( - "carriers" + self.status: Optional[MessagingV2RcsCountryStatus] = ( + MessagingV2RcsCountryStatus(payload.get("status")) + if payload.get("status") is not None + else None + ) + self.carriers: Optional[List[MessagingV2RcsCarrier]] = ( + [ + MessagingV2RcsCarrier(item) if isinstance(item, dict) else item + for item in payload.get("carriers") + ] + if payload.get("carriers") is not None + else None ) def to_dict(self): diff --git a/twilio/rest/messaging/v3/typing_indicator.py b/twilio/rest/messaging/v3/typing_indicator.py index 43f1732c6..ae66ae114 100644 --- a/twilio/rest/messaging/v3/typing_indicator.py +++ b/twilio/rest/messaging/v3/typing_indicator.py @@ -34,13 +34,11 @@ class TypingIndicatorRequest(object): def __init__(self, payload: Dict[str, Any]): - self.channel: Optional["TypingIndicatorInstance.str"] = payload.get( - "channel" - ) + self.channel: Optional[str] = payload.get("channel") self.message_id: Optional[str] = payload.get("messageId") self._from: Optional[str] = payload.get("from") self.to: Optional[str] = payload.get("to") - self.event: Optional["TypingIndicatorInstance.str"] = payload.get("event") + self.event: Optional[str] = payload.get("event") def to_dict(self): return { @@ -83,13 +81,11 @@ class TypingIndicatorRequest(object): def __init__(self, payload: Dict[str, Any]): - self.channel: Optional["TypingIndicatorInstance.str"] = payload.get( - "channel" - ) + self.channel: Optional[str] = payload.get("channel") self.message_id: Optional[str] = payload.get("messageId") self._from: Optional[str] = payload.get("from") self.to: Optional[str] = payload.get("to") - self.event: Optional["TypingIndicatorInstance.str"] = payload.get("event") + self.event: Optional[str] = payload.get("event") def to_dict(self): return { diff --git a/twilio/rest/numbers/v1/__init__.py b/twilio/rest/numbers/v1/__init__.py index a3f3cc084..59dd3d522 100644 --- a/twilio/rest/numbers/v1/__init__.py +++ b/twilio/rest/numbers/v1/__init__.py @@ -34,6 +34,10 @@ from twilio.rest.numbers.v1.signing_request_configuration import ( SigningRequestConfigurationList, ) +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 @@ -64,6 +68,10 @@ def __init__(self, domain: Domain): self._signing_request_configurations: Optional[ SigningRequestConfigurationList ] = None + 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 @@ -144,6 +152,30 @@ def signing_request_configurations(self) -> SigningRequestConfigurationList: self._signing_request_configurations = SigningRequestConfigurationList(self) return self._signing_request_configurations + @property + def sms_verifications(self) -> SmsVerificationList: + if self._sms_verifications is None: + self._sms_verifications = SmsVerificationList(self) + return self._sms_verifications + + @property + def sms_verification_checks(self) -> SmsVerificationCheckList: + if self._sms_verification_checks is None: + self._sms_verification_checks = SmsVerificationCheckList(self) + return self._sms_verification_checks + + @property + def voice_verifications(self) -> VoiceVerificationList: + if self._voice_verifications is None: + 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/bulk_eligibility.py b/twilio/rest/numbers/v1/bulk_eligibility.py index ed521218a..60f56e502 100644 --- a/twilio/rest/numbers/v1/bulk_eligibility.py +++ b/twilio/rest/numbers/v1/bulk_eligibility.py @@ -43,7 +43,9 @@ def __init__( self.request_id: Optional[str] = payload.get("request_id") self.url: Optional[str] = payload.get("url") - self.results: Optional[List[Dict[str, object]]] = payload.get("results") + self.results: Optional[List[Dict[str, Dict[str, object]]]] = payload.get( + "results" + ) self.friendly_name: Optional[str] = payload.get("friendly_name") self.status: Optional[str] = payload.get("status") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( diff --git a/twilio/rest/numbers/v1/porting_port_in.py b/twilio/rest/numbers/v1/porting_port_in.py index 53400a5fd..9824148a0 100644 --- a/twilio/rest/numbers/v1/porting_port_in.py +++ b/twilio/rest/numbers/v1/porting_port_in.py @@ -78,7 +78,9 @@ def __init__(self, payload: Dict[str, Any]): ) self.address_sid: Optional[str] = payload.get("address_sid") self.address: Optional[PortingPortInList.NumbersV1PortingAddress] = ( - payload.get("address") + PortingPortInList.NumbersV1PortingAddress(payload.get("address")) + if payload.get("address") is not None + else None ) self.authorized_representative: Optional[str] = payload.get( "authorized_representative" @@ -86,9 +88,7 @@ def __init__(self, payload: Dict[str, Any]): self.authorized_representative_email: Optional[str] = payload.get( "authorized_representative_email" ) - self.customer_type: Optional["PortingPortInInstance.str"] = payload.get( - "customer_type" - ) + self.customer_type: Optional[str] = payload.get("customer_type") self.authorized_representative_katakana: Optional[str] = payload.get( "authorized_representative_katakana" ) @@ -133,10 +133,27 @@ def __init__(self, payload: Dict[str, Any]): self.documents: Optional[List[str]] = payload.get("documents") self.phone_numbers: Optional[ List[PortingPortInList.NumbersV1PortingPortInCreatePhoneNumbers] - ] = payload.get("phone_numbers") + ] = ( + [ + ( + PortingPortInList.NumbersV1PortingPortInCreatePhoneNumbers(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("phone_numbers") + ] + if payload.get("phone_numbers") is not None + else None + ) self.losing_carrier_information: Optional[ PortingPortInList.NumbersV1PortingLosingCarrierInformation - ] = payload.get("losing_carrier_information") + ] = ( + PortingPortInList.NumbersV1PortingLosingCarrierInformation( + payload.get("losing_carrier_information") + ) + if payload.get("losing_carrier_information") is not None + else None + ) self.notification_emails: Optional[List[str]] = payload.get( "notification_emails" ) @@ -426,7 +443,9 @@ def __init__(self, payload: Dict[str, Any]): ) self.address_sid: Optional[str] = payload.get("address_sid") self.address: Optional[PortingPortInList.NumbersV1PortingAddress] = ( - payload.get("address") + PortingPortInList.NumbersV1PortingAddress(payload.get("address")) + if payload.get("address") is not None + else None ) self.authorized_representative: Optional[str] = payload.get( "authorized_representative" @@ -434,9 +453,7 @@ def __init__(self, payload: Dict[str, Any]): self.authorized_representative_email: Optional[str] = payload.get( "authorized_representative_email" ) - self.customer_type: Optional["PortingPortInInstance.str"] = payload.get( - "customer_type" - ) + self.customer_type: Optional[str] = payload.get("customer_type") self.authorized_representative_katakana: Optional[str] = payload.get( "authorized_representative_katakana" ) @@ -481,10 +498,27 @@ def __init__(self, payload: Dict[str, Any]): self.documents: Optional[List[str]] = payload.get("documents") self.phone_numbers: Optional[ List[PortingPortInList.NumbersV1PortingPortInCreatePhoneNumbers] - ] = payload.get("phone_numbers") + ] = ( + [ + ( + PortingPortInList.NumbersV1PortingPortInCreatePhoneNumbers(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("phone_numbers") + ] + if payload.get("phone_numbers") is not None + else None + ) self.losing_carrier_information: Optional[ PortingPortInList.NumbersV1PortingLosingCarrierInformation - ] = payload.get("losing_carrier_information") + ] = ( + PortingPortInList.NumbersV1PortingLosingCarrierInformation( + payload.get("losing_carrier_information") + ) + if payload.get("losing_carrier_information") is not None + else None + ) self.notification_emails: Optional[List[str]] = payload.get( "notification_emails" ) @@ -784,7 +818,9 @@ def __init__(self, payload: Dict[str, Any]): ) self.address_sid: Optional[str] = payload.get("address_sid") self.address: Optional[PortingPortInList.NumbersV1PortingAddress] = ( - payload.get("address") + PortingPortInList.NumbersV1PortingAddress(payload.get("address")) + if payload.get("address") is not None + else None ) self.authorized_representative: Optional[str] = payload.get( "authorized_representative" @@ -792,9 +828,7 @@ def __init__(self, payload: Dict[str, Any]): self.authorized_representative_email: Optional[str] = payload.get( "authorized_representative_email" ) - self.customer_type: Optional["PortingPortInInstance.str"] = payload.get( - "customer_type" - ) + self.customer_type: Optional[str] = payload.get("customer_type") self.authorized_representative_katakana: Optional[str] = payload.get( "authorized_representative_katakana" ) @@ -839,10 +873,27 @@ def __init__(self, payload: Dict[str, Any]): self.documents: Optional[List[str]] = payload.get("documents") self.phone_numbers: Optional[ List[PortingPortInList.NumbersV1PortingPortInCreatePhoneNumbers] - ] = payload.get("phone_numbers") + ] = ( + [ + ( + PortingPortInList.NumbersV1PortingPortInCreatePhoneNumbers(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("phone_numbers") + ] + if payload.get("phone_numbers") is not None + else None + ) self.losing_carrier_information: Optional[ PortingPortInList.NumbersV1PortingLosingCarrierInformation - ] = payload.get("losing_carrier_information") + ] = ( + PortingPortInList.NumbersV1PortingLosingCarrierInformation( + payload.get("losing_carrier_information") + ) + if payload.get("losing_carrier_information") is not None + else None + ) self.notification_emails: Optional[List[str]] = payload.get( "notification_emails" ) diff --git a/twilio/rest/numbers/v1/sender_id_registration.py b/twilio/rest/numbers/v1/sender_id_registration.py index 6995e6a84..c9087ffcf 100644 --- a/twilio/rest/numbers/v1/sender_id_registration.py +++ b/twilio/rest/numbers/v1/sender_id_registration.py @@ -47,7 +47,9 @@ def __init__(self, payload: Dict[str, Any]): self.status_callback_url: Optional[str] = payload.get("statusCallbackUrl") self.comments: Optional[str] = payload.get("comments") self.theme_set_id: Optional[str] = payload.get("themeSetId") - self.data: Optional[Dict[str, object]] = payload.get("data") + self.data: Optional[Dict[str, Dict[str, Dict[str, Dict[str, object]]]]] = ( + payload.get("data") + ) def to_dict(self): return { @@ -92,7 +94,7 @@ def __init__(self, version: Version, payload: Dict[str, Any]): self.status_callback_url: Optional[str] = payload.get("statusCallbackUrl") self.comments: Optional[str] = payload.get("comments") self.embedded_session: Optional[str] = payload.get("embeddedSession") - self.data: Optional[Dict[str, object]] = payload.get("data") + self.data: Optional[Dict[str, Dict[str, object]]] = payload.get("data") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("dateCreated") ) @@ -135,7 +137,9 @@ def __init__(self, payload: Dict[str, Any]): self.status_callback_url: Optional[str] = payload.get("statusCallbackUrl") self.comments: Optional[str] = payload.get("comments") self.theme_set_id: Optional[str] = payload.get("themeSetId") - self.data: Optional[Dict[str, object]] = payload.get("data") + self.data: Optional[Dict[str, Dict[str, Dict[str, Dict[str, object]]]]] = ( + payload.get("data") + ) def to_dict(self): return { diff --git a/twilio/rest/numbers/v1/sms_verification.py b/twilio/rest/numbers/v1/sms_verification.py new file mode 100644 index 000000000..71d0d2215 --- /dev/null +++ b/twilio/rest/numbers/v1/sms_verification.py @@ -0,0 +1,141 @@ +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, List, 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 SmsVerificationInstance(InstanceResource): + """ + :ivar to: The phone number being verified in E.164 format. + :ivar verification_sid: The unique SID of this verification resource. + :ivar send_code_attempts: An array of verification attempt objects. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.to: Optional[str] = payload.get("to") + self.verification_sid: Optional[str] = payload.get("verificationSid") + self.send_code_attempts: Optional[List[str]] = payload.get("sendCodeAttempts") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class SmsVerificationList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the SmsVerificationList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/CallerIds/SmsVerifications" + + 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) -> SmsVerificationInstance: + """ + Create the SmsVerificationInstance + + + :returns: The created SmsVerificationInstance + """ + payload, _, _ = self._create() + return SmsVerificationInstance(self._version, payload) + + def create_with_http_info(self) -> ApiResponse: + """ + Create the SmsVerificationInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create() + instance = SmsVerificationInstance(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) -> SmsVerificationInstance: + """ + Asynchronously create the SmsVerificationInstance + + + :returns: The created SmsVerificationInstance + """ + payload, _, _ = await self._create_async() + return SmsVerificationInstance(self._version, payload) + + async def create_with_http_info_async(self) -> ApiResponse: + """ + Asynchronously create the SmsVerificationInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async() + instance = SmsVerificationInstance(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/v1/sms_verification_check.py b/twilio/rest/numbers/v1/sms_verification_check.py new file mode 100644 index 000000000..f57035319 --- /dev/null +++ b/twilio/rest/numbers/v1/sms_verification_check.py @@ -0,0 +1,143 @@ +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 SmsVerificationCheckInstance(InstanceResource): + """ + :ivar to: The phone number that was verified in E.164 format. + :ivar verification_sid: The unique SID of this verification resource. + :ivar status: The status of the verification (pending, approved, canceled). + :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.verification_sid: Optional[str] = payload.get("verificationSid") + self.status: Optional[str] = payload.get("status") + self.caller_id_sid: Optional[str] = payload.get("callerIdSid") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class SmsVerificationCheckList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the SmsVerificationCheckList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/CallerIds/SmsVerificationChecks" + + 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) -> SmsVerificationCheckInstance: + """ + Create the SmsVerificationCheckInstance + + + :returns: The created SmsVerificationCheckInstance + """ + payload, _, _ = self._create() + return SmsVerificationCheckInstance(self._version, payload) + + def create_with_http_info(self) -> ApiResponse: + """ + Create the SmsVerificationCheckInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create() + instance = SmsVerificationCheckInstance(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) -> SmsVerificationCheckInstance: + """ + Asynchronously create the SmsVerificationCheckInstance + + + :returns: The created SmsVerificationCheckInstance + """ + payload, _, _ = await self._create_async() + return SmsVerificationCheckInstance(self._version, payload) + + async def create_with_http_info_async(self) -> ApiResponse: + """ + Asynchronously create the SmsVerificationCheckInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async() + instance = SmsVerificationCheckInstance(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/v1/voice_verification.py b/twilio/rest/numbers/v1/voice_verification.py new file mode 100644 index 000000000..5e41647d7 --- /dev/null +++ b/twilio/rest/numbers/v1/voice_verification.py @@ -0,0 +1,145 @@ +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 VoiceVerificationInstance(InstanceResource): + """ + :ivar account_sid: The Account SID that owns this verification. + :ivar phone_number: The phone number being verified in E.164 format. + :ivar friendly_name: A human-readable name for this caller ID. + :ivar validation_code: The 6-digit validation code to be entered during the call. + :ivar call_sid: The Call SID for the verification call. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("accountSid") + self.phone_number: Optional[str] = payload.get("phoneNumber") + self.friendly_name: Optional[str] = payload.get("friendlyName") + self.validation_code: Optional[str] = payload.get("validationCode") + self.call_sid: Optional[str] = payload.get("callSid") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class VoiceVerificationList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the VoiceVerificationList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/CallerIds/VoiceVerifications" + + 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) -> VoiceVerificationInstance: + """ + Create the VoiceVerificationInstance + + + :returns: The created VoiceVerificationInstance + """ + payload, _, _ = self._create() + return VoiceVerificationInstance(self._version, payload) + + def create_with_http_info(self) -> ApiResponse: + """ + Create the VoiceVerificationInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create() + instance = VoiceVerificationInstance(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) -> VoiceVerificationInstance: + """ + Asynchronously create the VoiceVerificationInstance + + + :returns: The created VoiceVerificationInstance + """ + payload, _, _ = await self._create_async() + return VoiceVerificationInstance(self._version, payload) + + async def create_with_http_info_async(self) -> ApiResponse: + """ + Asynchronously create the VoiceVerificationInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async() + instance = VoiceVerificationInstance(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/v1/voice_verification_check.py b/twilio/rest/numbers/v1/voice_verification_check.py new file mode 100644 index 000000000..28d201e55 --- /dev/null +++ b/twilio/rest/numbers/v1/voice_verification_check.py @@ -0,0 +1,139 @@ +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 1381c1d7a..3b9115d33 100644 --- a/twilio/rest/numbers/v2/application.py +++ b/twilio/rest/numbers/v2/application.py @@ -39,10 +39,22 @@ def __init__(self, payload: Dict[str, Any]): self.iso_country: Optional[str] = payload.get("iso_country") self.business_information: Optional[ ApplicationList.CreateShortCodeApplicationRequestBusinessInformation - ] = payload.get("business_information") + ] = ( + ApplicationList.CreateShortCodeApplicationRequestBusinessInformation( + payload.get("business_information") + ) + if payload.get("business_information") is not None + else None + ) self.setup: Optional[ ApplicationList.CreateShortCodeApplicationRequestSetup - ] = payload.get("setup") + ] = ( + ApplicationList.CreateShortCodeApplicationRequestSetup( + payload.get("setup") + ) + if payload.get("setup") is not None + else None + ) def to_dict(self): return { @@ -131,7 +143,7 @@ def __init__( "notification_emails" ) self.iso_country: Optional[str] = payload.get("iso_country") - self.state: Optional["ApplicationInstance.str"] = payload.get("state") + self.state: Optional[str] = payload.get("state") self.setup: Optional[str] = payload.get("setup") self.business_information: Optional[str] = payload.get("business_information") self.user_sign_up: Optional[str] = payload.get("user_sign_up") @@ -230,10 +242,22 @@ def __init__(self, payload: Dict[str, Any]): self.iso_country: Optional[str] = payload.get("iso_country") self.business_information: Optional[ ApplicationList.CreateShortCodeApplicationRequestBusinessInformation - ] = payload.get("business_information") + ] = ( + ApplicationList.CreateShortCodeApplicationRequestBusinessInformation( + payload.get("business_information") + ) + if payload.get("business_information") is not None + else None + ) self.setup: Optional[ ApplicationList.CreateShortCodeApplicationRequestSetup - ] = payload.get("setup") + ] = ( + ApplicationList.CreateShortCodeApplicationRequestSetup( + payload.get("setup") + ) + if payload.get("setup") is not None + else None + ) def to_dict(self): return { @@ -428,10 +452,22 @@ def __init__(self, payload: Dict[str, Any]): self.iso_country: Optional[str] = payload.get("iso_country") self.business_information: Optional[ ApplicationList.CreateShortCodeApplicationRequestBusinessInformation - ] = payload.get("business_information") + ] = ( + ApplicationList.CreateShortCodeApplicationRequestBusinessInformation( + payload.get("business_information") + ) + if payload.get("business_information") is not None + else None + ) self.setup: Optional[ ApplicationList.CreateShortCodeApplicationRequestSetup - ] = payload.get("setup") + ] = ( + ApplicationList.CreateShortCodeApplicationRequestSetup( + payload.get("setup") + ) + if payload.get("setup") is not None + else None + ) def to_dict(self): return { diff --git a/twilio/rest/numbers/v2/bulk_hosted_number_order.py b/twilio/rest/numbers/v2/bulk_hosted_number_order.py index 7ff4f50a4..056a7c76d 100644 --- a/twilio/rest/numbers/v2/bulk_hosted_number_order.py +++ b/twilio/rest/numbers/v2/bulk_hosted_number_order.py @@ -65,7 +65,9 @@ def __init__( self.total_count: Optional[int] = deserialize.integer( payload.get("total_count") ) - self.results: Optional[List[Dict[str, object]]] = payload.get("results") + self.results: Optional[List[Dict[str, Dict[str, object]]]] = payload.get( + "results" + ) self._solution = { "bulk_hosting_sid": bulk_hosting_sid or self.bulk_hosting_sid, diff --git a/twilio/rest/numbers/v2/regulatory_compliance/bundle/evaluation.py b/twilio/rest/numbers/v2/regulatory_compliance/bundle/evaluation.py index 34107f1ca..87edeece4 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/bundle/evaluation.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/bundle/evaluation.py @@ -54,7 +54,9 @@ def __init__( self.regulation_sid: Optional[str] = payload.get("regulation_sid") self.bundle_sid: Optional[str] = payload.get("bundle_sid") self.status: Optional["EvaluationInstance.Status"] = payload.get("status") - self.results: Optional[List[Dict[str, object]]] = payload.get("results") + self.results: Optional[List[Dict[str, Dict[str, Dict[str, object]]]]] = ( + payload.get("results") + ) self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) diff --git a/twilio/rest/numbers/v2/regulatory_compliance/end_user_type.py b/twilio/rest/numbers/v2/regulatory_compliance/end_user_type.py index cf6534bbe..e41ffd06f 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/end_user_type.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/end_user_type.py @@ -39,7 +39,9 @@ def __init__( self.sid: Optional[str] = payload.get("sid") self.friendly_name: Optional[str] = payload.get("friendly_name") self.machine_name: Optional[str] = payload.get("machine_name") - self.fields: Optional[List[Dict[str, object]]] = payload.get("fields") + self.fields: Optional[List[Dict[str, Dict[str, object]]]] = payload.get( + "fields" + ) self.url: Optional[str] = payload.get("url") self._solution = { diff --git a/twilio/rest/numbers/v2/regulatory_compliance/supporting_document.py b/twilio/rest/numbers/v2/regulatory_compliance/supporting_document.py index abbddb13c..49dd70408 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/supporting_document.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/supporting_document.py @@ -61,7 +61,9 @@ def __init__( "status" ) self.failure_reason: Optional[str] = payload.get("failure_reason") - self.errors: Optional[List[Dict[str, object]]] = payload.get("errors") + self.errors: Optional[ + List[Dict[str, Dict[str, Dict[str, Dict[str, object]]]]] + ] = payload.get("errors") self.type: Optional[str] = payload.get("type") self.attributes: Optional[Dict[str, object]] = payload.get("attributes") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( diff --git a/twilio/rest/numbers/v2/regulatory_compliance/supporting_document_type.py b/twilio/rest/numbers/v2/regulatory_compliance/supporting_document_type.py index d2de945f9..103da91bc 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/supporting_document_type.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/supporting_document_type.py @@ -39,7 +39,9 @@ def __init__( self.sid: Optional[str] = payload.get("sid") self.friendly_name: Optional[str] = payload.get("friendly_name") self.machine_name: Optional[str] = payload.get("machine_name") - self.fields: Optional[List[Dict[str, object]]] = payload.get("fields") + self.fields: Optional[List[Dict[str, Dict[str, object]]]] = payload.get( + "fields" + ) self.url: Optional[str] = payload.get("url") self._solution = { diff --git a/twilio/rest/oauth/v1/oauth_authorization_server.py b/twilio/rest/oauth/v2/oauth_authorization_server.py similarity index 83% rename from twilio/rest/oauth/v1/oauth_authorization_server.py rename to twilio/rest/oauth/v2/oauth_authorization_server.py index 4fcdd357c..e5a375604 100644 --- a/twilio/rest/oauth/v1/oauth_authorization_server.py +++ b/twilio/rest/oauth/v2/oauth_authorization_server.py @@ -4,15 +4,15 @@ | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - Twilio - Oauth - This is the public Twilio REST API. + User OAuth API + User OAuth 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 typing import Any, Dict, List, Optional from twilio.base import values from twilio.base.api_response import ApiResponse @@ -40,18 +40,18 @@ def __init__(self, version: Version, payload: Dict[str, Any]): "authorization_endpoint" ) self.token_endpoint: Optional[str] = payload.get("token_endpoint") - self.response_types_supported: Optional[ - "OauthAuthorizationServerInstance.str]" - ] = payload.get("response_types_supported") - self.grant_types_supported: Optional[ - "OauthAuthorizationServerInstance.str]" - ] = payload.get("grant_types_supported") - self.code_challenge_methods_supported: Optional[ - "OauthAuthorizationServerInstance.str]" - ] = payload.get("code_challenge_methods_supported") - self.token_endpoint_auth_methods_supported: Optional[ - "OauthAuthorizationServerInstance.str]" - ] = payload.get("token_endpoint_auth_methods_supported") + self.response_types_supported: Optional[List[str]] = payload.get( + "response_types_supported" + ) + self.grant_types_supported: Optional[List[str]] = payload.get( + "grant_types_supported" + ) + self.code_challenge_methods_supported: Optional[List[str]] = payload.get( + "code_challenge_methods_supported" + ) + self.token_endpoint_auth_methods_supported: Optional[List[str]] = payload.get( + "token_endpoint_auth_methods_supported" + ) def __repr__(self) -> str: """ @@ -60,7 +60,7 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" class OauthAuthorizationServerList(ListResource): @@ -154,4 +154,4 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" diff --git a/twilio/rest/oauth/v2/token.py b/twilio/rest/oauth/v2/token.py index 07bff732c..35e1f9ef1 100644 --- a/twilio/rest/oauth/v2/token.py +++ b/twilio/rest/oauth/v2/token.py @@ -64,8 +64,8 @@ def __init__(self, version: Version): def _create( self, + grant_type: str, account_sid: Union[str, object] = values.unset, - grant_type: Union[str, object] = values.unset, client_id: Union[str, object] = values.unset, client_secret: Union[str, object] = values.unset, code: Union[str, object] = values.unset, @@ -113,8 +113,8 @@ def _create( def create( self, + grant_type: str, account_sid: Union[str, object] = values.unset, - grant_type: Union[str, object] = values.unset, client_id: Union[str, object] = values.unset, client_secret: Union[str, object] = values.unset, code: Union[str, object] = values.unset, @@ -127,8 +127,8 @@ def create( """ Create the TokenInstance - :param account_sid: Optional Account SID to perform on behalf of requests. :param grant_type: Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + :param account_sid: Optional Account SID to perform on behalf of requests. :param client_id: A 34 character string that uniquely identifies this OAuth App. :param client_secret: The credential for confidential OAuth App. :param code: JWT token related to the authorization code grant type. @@ -141,8 +141,8 @@ def create( :returns: The created TokenInstance """ payload, _, _ = self._create( - account_sid=account_sid, grant_type=grant_type, + account_sid=account_sid, client_id=client_id, client_secret=client_secret, code=code, @@ -156,8 +156,8 @@ def create( def create_with_http_info( self, + grant_type: str, account_sid: Union[str, object] = values.unset, - grant_type: Union[str, object] = values.unset, client_id: Union[str, object] = values.unset, client_secret: Union[str, object] = values.unset, code: Union[str, object] = values.unset, @@ -170,8 +170,8 @@ def create_with_http_info( """ Create the TokenInstance and return response metadata - :param account_sid: Optional Account SID to perform on behalf of requests. :param grant_type: Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + :param account_sid: Optional Account SID to perform on behalf of requests. :param client_id: A 34 character string that uniquely identifies this OAuth App. :param client_secret: The credential for confidential OAuth App. :param code: JWT token related to the authorization code grant type. @@ -184,8 +184,8 @@ def create_with_http_info( :returns: ApiResponse with instance, status code, and headers """ payload, status_code, headers = self._create( - account_sid=account_sid, grant_type=grant_type, + account_sid=account_sid, client_id=client_id, client_secret=client_secret, code=code, @@ -200,8 +200,8 @@ def create_with_http_info( async def _create_async( self, + grant_type: str, account_sid: Union[str, object] = values.unset, - grant_type: Union[str, object] = values.unset, client_id: Union[str, object] = values.unset, client_secret: Union[str, object] = values.unset, code: Union[str, object] = values.unset, @@ -249,8 +249,8 @@ async def _create_async( async def create_async( self, + grant_type: str, account_sid: Union[str, object] = values.unset, - grant_type: Union[str, object] = values.unset, client_id: Union[str, object] = values.unset, client_secret: Union[str, object] = values.unset, code: Union[str, object] = values.unset, @@ -263,8 +263,8 @@ async def create_async( """ Asynchronously create the TokenInstance - :param account_sid: Optional Account SID to perform on behalf of requests. :param grant_type: Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + :param account_sid: Optional Account SID to perform on behalf of requests. :param client_id: A 34 character string that uniquely identifies this OAuth App. :param client_secret: The credential for confidential OAuth App. :param code: JWT token related to the authorization code grant type. @@ -277,8 +277,8 @@ async def create_async( :returns: The created TokenInstance """ payload, _, _ = await self._create_async( - account_sid=account_sid, grant_type=grant_type, + account_sid=account_sid, client_id=client_id, client_secret=client_secret, code=code, @@ -292,8 +292,8 @@ async def create_async( async def create_with_http_info_async( self, + grant_type: str, account_sid: Union[str, object] = values.unset, - grant_type: Union[str, object] = values.unset, client_id: Union[str, object] = values.unset, client_secret: Union[str, object] = values.unset, code: Union[str, object] = values.unset, @@ -306,8 +306,8 @@ async def create_with_http_info_async( """ Asynchronously create the TokenInstance and return response metadata - :param account_sid: Optional Account SID to perform on behalf of requests. :param grant_type: Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + :param account_sid: Optional Account SID to perform on behalf of requests. :param client_id: A 34 character string that uniquely identifies this OAuth App. :param client_secret: The credential for confidential OAuth App. :param code: JWT token related to the authorization code grant type. @@ -320,8 +320,8 @@ async def create_with_http_info_async( :returns: ApiResponse with instance, status code, and headers """ payload, status_code, headers = await self._create_async( - account_sid=account_sid, grant_type=grant_type, + account_sid=account_sid, client_id=client_id, client_secret=client_secret, code=code, diff --git a/twilio/rest/preview_iam/versionless/organization/account.py b/twilio/rest/preview_iam/versionless/organization/account.py index 3ee97bd28..0528c3b03 100644 --- a/twilio/rest/preview_iam/versionless/organization/account.py +++ b/twilio/rest/preview_iam/versionless/organization/account.py @@ -43,7 +43,7 @@ def __init__( self.account_sid: Optional[str] = payload.get("account_sid") self.friendly_name: Optional[str] = payload.get("friendly_name") - self.status: Optional["AccountInstance.str"] = payload.get("status") + self.status: Optional[str] = payload.get("status") self.owner_sid: Optional[str] = payload.get("owner_sid") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") diff --git a/twilio/rest/preview_iam/versionless/organization/user.py b/twilio/rest/preview_iam/versionless/organization/user.py index 8299913b2..c5587ad92 100644 --- a/twilio/rest/preview_iam/versionless/organization/user.py +++ b/twilio/rest/preview_iam/versionless/organization/user.py @@ -114,8 +114,17 @@ class ScimPatchRequest(object): def __init__(self, payload: Dict[str, Any]): self.schemas: Optional[List[str]] = payload.get("schemas") - self.operations: Optional[List[UserList.ScimPatchOperation]] = payload.get( - "Operations" + self.operations: Optional[List[UserList.ScimPatchOperation]] = ( + [ + ( + UserList.ScimPatchOperation(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("Operations") + ] + if payload.get("Operations") is not None + else None ) def to_dict(self): @@ -154,17 +163,30 @@ def __init__(self, payload: Dict[str, Any]): self.external_id: Optional[str] = payload.get("externalId") self.user_name: Optional[str] = payload.get("userName") self.display_name: Optional[str] = payload.get("displayName") - self.name: Optional[UserList.ScimName] = payload.get("name") - self.emails: Optional[List[UserList.ScimEmailAddress]] = payload.get( - "emails" + self.name: Optional[UserList.ScimName] = ( + UserList.ScimName(payload.get("name")) + if payload.get("name") is not None + else None + ) + self.emails: Optional[List[UserList.ScimEmailAddress]] = ( + [ + UserList.ScimEmailAddress(item) if isinstance(item, dict) else item + for item in payload.get("emails") + ] + if payload.get("emails") is not None + else None ) self.active: Optional[bool] = payload.get("active") self.locale: Optional[str] = payload.get("locale") self.timezone: Optional[str] = payload.get("timezone") self.schemas: Optional[List[str]] = payload.get("schemas") - self.meta: Optional[UserList.ScimMeta] = payload.get("meta") + self.meta: Optional[UserList.ScimMeta] = ( + UserList.ScimMeta(payload.get("meta")) + if payload.get("meta") is not None + else None + ) self.detail: Optional[str] = payload.get("detail") - self.scim_type: Optional["UserInstance.str"] = payload.get("scimType") + self.scim_type: Optional[str] = payload.get("scimType") self.status: Optional[str] = payload.get("status") self.code: Optional[int] = payload.get("code") self.more_info: Optional[str] = payload.get("moreInfo") @@ -225,15 +247,15 @@ def __init__( self.external_id: Optional[str] = payload.get("externalId") self.user_name: Optional[str] = payload.get("userName") self.display_name: Optional[str] = payload.get("displayName") - self.name: Optional[UserList.str] = payload.get("name") - self.emails: Optional[List[UserList.str]] = payload.get("emails") + self.name: Optional[UserList.ScimName] = payload.get("name") + self.emails: Optional[List[UserList.ScimEmailAddress]] = payload.get("emails") self.active: Optional[bool] = payload.get("active") self.locale: Optional[str] = payload.get("locale") self.timezone: Optional[str] = payload.get("timezone") self.schemas: Optional[List[str]] = payload.get("schemas") - self.meta: Optional[UserList.str] = payload.get("meta") + self.meta: Optional[UserList.ScimMeta] = payload.get("meta") self.detail: Optional[str] = payload.get("detail") - self.scim_type: Optional["UserInstance.str"] = payload.get("scimType") + self.scim_type: Optional[str] = payload.get("scimType") self.status: Optional[str] = payload.get("status") self.code: Optional[int] = payload.get("code") self.more_info: Optional[str] = payload.get("moreInfo") @@ -534,8 +556,17 @@ class ScimPatchRequest(object): def __init__(self, payload: Dict[str, Any]): self.schemas: Optional[List[str]] = payload.get("schemas") - self.operations: Optional[List[UserList.ScimPatchOperation]] = payload.get( - "Operations" + self.operations: Optional[List[UserList.ScimPatchOperation]] = ( + [ + ( + UserList.ScimPatchOperation(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("Operations") + ] + if payload.get("Operations") is not None + else None ) def to_dict(self): @@ -574,17 +605,30 @@ def __init__(self, payload: Dict[str, Any]): self.external_id: Optional[str] = payload.get("externalId") self.user_name: Optional[str] = payload.get("userName") self.display_name: Optional[str] = payload.get("displayName") - self.name: Optional[UserList.ScimName] = payload.get("name") - self.emails: Optional[List[UserList.ScimEmailAddress]] = payload.get( - "emails" + self.name: Optional[UserList.ScimName] = ( + UserList.ScimName(payload.get("name")) + if payload.get("name") is not None + else None + ) + self.emails: Optional[List[UserList.ScimEmailAddress]] = ( + [ + UserList.ScimEmailAddress(item) if isinstance(item, dict) else item + for item in payload.get("emails") + ] + if payload.get("emails") is not None + else None ) self.active: Optional[bool] = payload.get("active") self.locale: Optional[str] = payload.get("locale") self.timezone: Optional[str] = payload.get("timezone") self.schemas: Optional[List[str]] = payload.get("schemas") - self.meta: Optional[UserList.ScimMeta] = payload.get("meta") + self.meta: Optional[UserList.ScimMeta] = ( + UserList.ScimMeta(payload.get("meta")) + if payload.get("meta") is not None + else None + ) self.detail: Optional[str] = payload.get("detail") - self.scim_type: Optional["UserInstance.str"] = payload.get("scimType") + self.scim_type: Optional[str] = payload.get("scimType") self.status: Optional[str] = payload.get("status") self.code: Optional[int] = payload.get("code") self.more_info: Optional[str] = payload.get("moreInfo") @@ -1211,8 +1255,17 @@ class ScimPatchRequest(object): def __init__(self, payload: Dict[str, Any]): self.schemas: Optional[List[str]] = payload.get("schemas") - self.operations: Optional[List[UserList.ScimPatchOperation]] = payload.get( - "Operations" + self.operations: Optional[List[UserList.ScimPatchOperation]] = ( + [ + ( + UserList.ScimPatchOperation(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("Operations") + ] + if payload.get("Operations") is not None + else None ) def to_dict(self): @@ -1251,17 +1304,30 @@ def __init__(self, payload: Dict[str, Any]): self.external_id: Optional[str] = payload.get("externalId") self.user_name: Optional[str] = payload.get("userName") self.display_name: Optional[str] = payload.get("displayName") - self.name: Optional[UserList.ScimName] = payload.get("name") - self.emails: Optional[List[UserList.ScimEmailAddress]] = payload.get( - "emails" + self.name: Optional[UserList.ScimName] = ( + UserList.ScimName(payload.get("name")) + if payload.get("name") is not None + else None + ) + self.emails: Optional[List[UserList.ScimEmailAddress]] = ( + [ + UserList.ScimEmailAddress(item) if isinstance(item, dict) else item + for item in payload.get("emails") + ] + if payload.get("emails") is not None + else None ) self.active: Optional[bool] = payload.get("active") self.locale: Optional[str] = payload.get("locale") self.timezone: Optional[str] = payload.get("timezone") self.schemas: Optional[List[str]] = payload.get("schemas") - self.meta: Optional[UserList.ScimMeta] = payload.get("meta") + self.meta: Optional[UserList.ScimMeta] = ( + UserList.ScimMeta(payload.get("meta")) + if payload.get("meta") is not None + else None + ) self.detail: Optional[str] = payload.get("detail") - self.scim_type: Optional["UserInstance.str"] = payload.get("scimType") + self.scim_type: Optional[str] = payload.get("scimType") self.status: Optional[str] = payload.get("status") self.code: Optional[int] = payload.get("code") self.more_info: Optional[str] = payload.get("moreInfo") diff --git a/twilio/rest/serverless/v1/service/build/__init__.py b/twilio/rest/serverless/v1/service/build/__init__.py index 01c185602..ed5eb5b80 100644 --- a/twilio/rest/serverless/v1/service/build/__init__.py +++ b/twilio/rest/serverless/v1/service/build/__init__.py @@ -66,7 +66,7 @@ class Status(object): :ivar links: """ - def __init__(self, version: Version, payload:Dict[str, Any], service_sid: str, sid: Optional[str] = None): + def __init__(self, version: Version, payload: Dict[str, Any], service_sid: str, sid: Optional[str] = None): super().__init__(version) @@ -74,9 +74,9 @@ def __init__(self, version: Version, payload:Dict[str, Any], service_sid: str, s self.account_sid: Optional[str] = payload.get("account_sid") self.service_sid: Optional[str] = payload.get("service_sid") self.status: Optional["BuildInstance.Status"] = payload.get("status") - self.asset_versions: Optional[List[Dict[str, object]]] = payload.get("asset_versions") - self.function_versions: Optional[List[Dict[str, object]]] = payload.get("function_versions") - self.dependencies: Optional[List[Dict[str, object]]] = payload.get("dependencies") + self.asset_versions: Optional[List[Dict[str, Dict[str, Dict[str, object]]]]] = payload.get("asset_versions") + self.function_versions: Optional[List[Dict[str, Dict[str, Dict[str, object]]]]] = payload.get("function_versions") + self.dependencies: Optional[List[Dict[str, Dict[str, Dict[str, object]]]]] = payload.get("dependencies") self.runtime: Optional["BuildInstance.Runtime"] = payload.get("runtime") self.date_created: Optional[datetime] = deserialize.iso8601_datetime(payload.get("date_created")) self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(payload.get("date_updated")) diff --git a/twilio/rest/serverless/v1/service/build/build_status.py b/twilio/rest/serverless/v1/service/build/build_status.py index 03a81818c..dc81dac28 100644 --- a/twilio/rest/serverless/v1/service/build/build_status.py +++ b/twilio/rest/serverless/v1/service/build/build_status.py @@ -46,7 +46,7 @@ class Status(object): :ivar url: The absolute URL of the Build Status resource. """ - def __init__(self, version: Version, payload:Dict[str, Any], service_sid: str, sid: str): + def __init__(self, version: Version, payload: Dict[str, Any], service_sid: str, sid: str): super().__init__(version) diff --git a/twilio/rest/studio/v2/flow/__init__.py b/twilio/rest/studio/v2/flow/__init__.py index c13e10be4..64181368b 100644 --- a/twilio/rest/studio/v2/flow/__init__.py +++ b/twilio/rest/studio/v2/flow/__init__.py @@ -65,8 +65,12 @@ def __init__( self.revision: Optional[int] = deserialize.integer(payload.get("revision")) self.commit_message: Optional[str] = payload.get("commit_message") self.valid: Optional[bool] = payload.get("valid") - self.errors: Optional[List[Dict[str, object]]] = payload.get("errors") - self.warnings: Optional[List[Dict[str, object]]] = payload.get("warnings") + self.errors: Optional[ + List[Dict[str, Dict[str, Dict[str, Dict[str, object]]]]] + ] = payload.get("errors") + self.warnings: Optional[ + List[Dict[str, Dict[str, Dict[str, Dict[str, object]]]]] + ] = payload.get("warnings") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) diff --git a/twilio/rest/studio/v2/flow/flow_revision.py b/twilio/rest/studio/v2/flow/flow_revision.py index 046e08d7c..c96b39e29 100644 --- a/twilio/rest/studio/v2/flow/flow_revision.py +++ b/twilio/rest/studio/v2/flow/flow_revision.py @@ -63,7 +63,9 @@ def __init__( self.revision: Optional[int] = deserialize.integer(payload.get("revision")) self.commit_message: Optional[str] = payload.get("commit_message") self.valid: Optional[bool] = payload.get("valid") - self.errors: Optional[List[Dict[str, object]]] = payload.get("errors") + self.errors: Optional[List[Dict[str, Dict[str, object]]]] = payload.get( + "errors" + ) self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) diff --git a/twilio/rest/supersim/v1/network.py b/twilio/rest/supersim/v1/network.py index c89787b80..bae5d5143 100644 --- a/twilio/rest/supersim/v1/network.py +++ b/twilio/rest/supersim/v1/network.py @@ -40,7 +40,9 @@ def __init__( self.friendly_name: Optional[str] = payload.get("friendly_name") self.url: Optional[str] = payload.get("url") self.iso_country: Optional[str] = payload.get("iso_country") - self.identifiers: Optional[List[Dict[str, object]]] = payload.get("identifiers") + self.identifiers: Optional[List[Dict[str, Dict[str, object]]]] = payload.get( + "identifiers" + ) self._solution = { "sid": sid or self.sid, diff --git a/twilio/rest/supersim/v1/network_access_profile/network_access_profile_network.py b/twilio/rest/supersim/v1/network_access_profile/network_access_profile_network.py index 7386d6075..7e6e38016 100644 --- a/twilio/rest/supersim/v1/network_access_profile/network_access_profile_network.py +++ b/twilio/rest/supersim/v1/network_access_profile/network_access_profile_network.py @@ -47,7 +47,9 @@ def __init__( ) self.friendly_name: Optional[str] = payload.get("friendly_name") self.iso_country: Optional[str] = payload.get("iso_country") - self.identifiers: Optional[List[Dict[str, object]]] = payload.get("identifiers") + self.identifiers: Optional[List[Dict[str, Dict[str, Dict[str, object]]]]] = ( + payload.get("identifiers") + ) self.url: Optional[str] = payload.get("url") self._solution = { diff --git a/twilio/rest/trusthub/v1/a2_p_brand_registration.py b/twilio/rest/trusthub/v1/a2_p_brand_registration.py index de712d4fa..46a3d4984 100644 --- a/twilio/rest/trusthub/v1/a2_p_brand_registration.py +++ b/twilio/rest/trusthub/v1/a2_p_brand_registration.py @@ -57,9 +57,7 @@ class TrusthubV1A2pBrandRegistrationRequest(object): def __init__(self, payload: Dict[str, Any]): - self.brand_type: Optional["A2PBrandRegistrationInstance.str"] = payload.get( - "brandType" - ) + self.brand_type: Optional[str] = payload.get("brandType") self.theme_set_id: Optional[str] = payload.get("themeSetId") self.friendly_name: Optional[str] = payload.get("friendlyName") self.notification_email: Optional[str] = payload.get("notificationEmail") @@ -211,9 +209,7 @@ class TrusthubV1A2pBrandRegistrationRequest(object): def __init__(self, payload: Dict[str, Any]): - self.brand_type: Optional["A2PBrandRegistrationInstance.str"] = payload.get( - "brandType" - ) + self.brand_type: Optional[str] = payload.get("brandType") self.theme_set_id: Optional[str] = payload.get("themeSetId") self.friendly_name: Optional[str] = payload.get("friendlyName") self.notification_email: Optional[str] = payload.get("notificationEmail") diff --git a/twilio/rest/trusthub/v1/customer_profiles/__init__.py b/twilio/rest/trusthub/v1/customer_profiles/__init__.py index 5ba9df5ec..f4cda9fe4 100644 --- a/twilio/rest/trusthub/v1/customer_profiles/__init__.py +++ b/twilio/rest/trusthub/v1/customer_profiles/__init__.py @@ -80,7 +80,9 @@ def __init__( ) self.url: Optional[str] = payload.get("url") self.links: Optional[Dict[str, object]] = payload.get("links") - self.errors: Optional[List[Dict[str, object]]] = payload.get("errors") + self.errors: Optional[ + List[Dict[str, Dict[str, Dict[str, Dict[str, object]]]]] + ] = payload.get("errors") self._solution = { "sid": sid or self.sid, diff --git a/twilio/rest/trusthub/v1/customer_profiles/customer_profiles_evaluations.py b/twilio/rest/trusthub/v1/customer_profiles/customer_profiles_evaluations.py index 7094e1c0f..1c47b1b79 100644 --- a/twilio/rest/trusthub/v1/customer_profiles/customer_profiles_evaluations.py +++ b/twilio/rest/trusthub/v1/customer_profiles/customer_profiles_evaluations.py @@ -56,7 +56,9 @@ def __init__( self.status: Optional["CustomerProfilesEvaluationsInstance.Status"] = ( payload.get("status") ) - self.results: Optional[List[Dict[str, object]]] = payload.get("results") + self.results: Optional[List[Dict[str, Dict[str, Dict[str, object]]]]] = ( + payload.get("results") + ) self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) diff --git a/twilio/rest/trusthub/v1/end_user_type.py b/twilio/rest/trusthub/v1/end_user_type.py index 8f2da577f..453379f83 100644 --- a/twilio/rest/trusthub/v1/end_user_type.py +++ b/twilio/rest/trusthub/v1/end_user_type.py @@ -39,7 +39,9 @@ def __init__( self.sid: Optional[str] = payload.get("sid") self.friendly_name: Optional[str] = payload.get("friendly_name") self.machine_name: Optional[str] = payload.get("machine_name") - self.fields: Optional[List[Dict[str, object]]] = payload.get("fields") + self.fields: Optional[List[Dict[str, Dict[str, object]]]] = payload.get( + "fields" + ) self.url: Optional[str] = payload.get("url") self._solution = { diff --git a/twilio/rest/trusthub/v1/supporting_document_type.py b/twilio/rest/trusthub/v1/supporting_document_type.py index 2ae6cb345..2fa17a6b6 100644 --- a/twilio/rest/trusthub/v1/supporting_document_type.py +++ b/twilio/rest/trusthub/v1/supporting_document_type.py @@ -39,7 +39,9 @@ def __init__( self.sid: Optional[str] = payload.get("sid") self.friendly_name: Optional[str] = payload.get("friendly_name") self.machine_name: Optional[str] = payload.get("machine_name") - self.fields: Optional[List[Dict[str, object]]] = payload.get("fields") + self.fields: Optional[List[Dict[str, Dict[str, object]]]] = payload.get( + "fields" + ) self.url: Optional[str] = payload.get("url") self._solution = { diff --git a/twilio/rest/trusthub/v1/trust_products/__init__.py b/twilio/rest/trusthub/v1/trust_products/__init__.py index 3c2553dbb..fadf79be3 100644 --- a/twilio/rest/trusthub/v1/trust_products/__init__.py +++ b/twilio/rest/trusthub/v1/trust_products/__init__.py @@ -80,7 +80,9 @@ def __init__( ) self.url: Optional[str] = payload.get("url") self.links: Optional[Dict[str, object]] = payload.get("links") - self.errors: Optional[List[Dict[str, object]]] = payload.get("errors") + self.errors: Optional[ + List[Dict[str, Dict[str, Dict[str, Dict[str, object]]]]] + ] = payload.get("errors") self._solution = { "sid": sid or self.sid, diff --git a/twilio/rest/trusthub/v1/trust_products/trust_products_evaluations.py b/twilio/rest/trusthub/v1/trust_products/trust_products_evaluations.py index f27af2615..b0c58d241 100644 --- a/twilio/rest/trusthub/v1/trust_products/trust_products_evaluations.py +++ b/twilio/rest/trusthub/v1/trust_products/trust_products_evaluations.py @@ -56,7 +56,9 @@ def __init__( self.status: Optional["TrustProductsEvaluationsInstance.Status"] = payload.get( "status" ) - self.results: Optional[List[Dict[str, object]]] = payload.get("results") + self.results: Optional[List[Dict[str, Dict[str, Dict[str, object]]]]] = ( + payload.get("results") + ) self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) diff --git a/twilio/rest/verify/v2/service/approve_challenge.py b/twilio/rest/verify/v2/service/approve_challenge.py index 52af951f0..d6d7e26ac 100644 --- a/twilio/rest/verify/v2/service/approve_challenge.py +++ b/twilio/rest/verify/v2/service/approve_challenge.py @@ -37,13 +37,19 @@ def __init__(self, payload: Dict[str, Any]): self.id: Optional[str] = payload.get("id") self.raw_id: Optional[str] = payload.get("rawId") - self.authenticator_attachment: Optional["ApproveChallengeInstance.str"] = ( - payload.get("authenticatorAttachment") + self.authenticator_attachment: Optional[str] = payload.get( + "authenticatorAttachment" ) - self.type: Optional["ApproveChallengeInstance.str"] = payload.get("type") + self.type: Optional[str] = payload.get("type") self.response: Optional[ ApproveChallengeList.ApprovePasskeysChallengeRequestResponse - ] = payload.get("response") + ] = ( + ApproveChallengeList.ApprovePasskeysChallengeRequestResponse( + payload.get("response") + ) + if payload.get("response") is not None + else None + ) def to_dict(self): return { @@ -122,16 +128,12 @@ def __init__(self, version: Version, payload: Dict[str, Any], service_sid: str): self.expiration_date: Optional[datetime] = deserialize.iso8601_datetime( payload.get("expiration_date") ) - self.status: Optional["ApproveChallengeInstance.str"] = payload.get("status") - self.responded_reason: Optional["ApproveChallengeInstance.str"] = payload.get( - "responded_reason" - ) + self.status: Optional[str] = payload.get("status") + self.responded_reason: Optional[str] = payload.get("responded_reason") self.details: Optional[Dict[str, object]] = payload.get("details") self.hidden_details: Optional[Dict[str, object]] = payload.get("hidden_details") self.metadata: Optional[Dict[str, object]] = payload.get("metadata") - self.factor_type: Optional["ApproveChallengeInstance.str"] = payload.get( - "factor_type" - ) + self.factor_type: Optional[str] = payload.get("factor_type") self.url: Optional[str] = payload.get("url") self.links: Optional[Dict[str, object]] = payload.get("links") self.options: Optional[Dict[str, object]] = payload.get("options") @@ -165,13 +167,19 @@ def __init__(self, payload: Dict[str, Any]): self.id: Optional[str] = payload.get("id") self.raw_id: Optional[str] = payload.get("rawId") - self.authenticator_attachment: Optional["ApproveChallengeInstance.str"] = ( - payload.get("authenticatorAttachment") + self.authenticator_attachment: Optional[str] = payload.get( + "authenticatorAttachment" ) - self.type: Optional["ApproveChallengeInstance.str"] = payload.get("type") + self.type: Optional[str] = payload.get("type") self.response: Optional[ ApproveChallengeList.ApprovePasskeysChallengeRequestResponse - ] = payload.get("response") + ] = ( + ApproveChallengeList.ApprovePasskeysChallengeRequestResponse( + payload.get("response") + ) + if payload.get("response") is not None + else None + ) def to_dict(self): return { diff --git a/twilio/rest/verify/v2/service/new_challenge.py b/twilio/rest/verify/v2/service/new_challenge.py index 74107dd04..07266b3ea 100644 --- a/twilio/rest/verify/v2/service/new_challenge.py +++ b/twilio/rest/verify/v2/service/new_challenge.py @@ -13,7 +13,7 @@ """ from datetime import datetime -from typing import Any, Dict, Optional +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 @@ -84,16 +84,12 @@ def __init__(self, version: Version, payload: Dict[str, Any], service_sid: str): self.expiration_date: Optional[datetime] = deserialize.iso8601_datetime( payload.get("expiration_date") ) - self.status: Optional["ApproveChallengeInstance.str"] = payload.get("status") - self.responded_reason: Optional["ApproveChallengeInstance.str"] = payload.get( - "responded_reason" - ) + self.status: Optional[str] = payload.get("status") + self.responded_reason: Optional[str] = payload.get("responded_reason") self.details: Optional[Dict[str, object]] = payload.get("details") self.hidden_details: Optional[Dict[str, object]] = payload.get("hidden_details") self.metadata: Optional[Dict[str, object]] = payload.get("metadata") - self.factor_type: Optional["ApproveChallengeInstance.str"] = payload.get( - "factor_type" - ) + self.factor_type: Optional[str] = payload.get("factor_type") self.url: Optional[str] = payload.get("url") self.links: Optional[Dict[str, object]] = payload.get("links") self.options: Optional[Dict[str, object]] = payload.get("options") @@ -120,7 +116,10 @@ def _proxy(self) -> "NewChallengeContext": return self._context def create( - self, create_passkeys_challenge_request: CreatePasskeysChallengeRequest + self, + create_passkeys_challenge_request: Union[ + CreatePasskeysChallengeRequest, object + ] = values.unset, ) -> "NewChallengeInstance": """ Create the NewChallengeInstance @@ -130,11 +129,14 @@ def create( :returns: The created NewChallengeInstance """ return self._proxy.create( - create_passkeys_challenge_request, + create_passkeys_challenge_request=create_passkeys_challenge_request, ) async def create_async( - self, create_passkeys_challenge_request: CreatePasskeysChallengeRequest + self, + create_passkeys_challenge_request: Union[ + CreatePasskeysChallengeRequest, object + ] = values.unset, ) -> "NewChallengeInstance": """ Asynchronous coroutine to create the NewChallengeInstance @@ -144,11 +146,14 @@ async def create_async( :returns: The created NewChallengeInstance """ return await self._proxy.create_async( - create_passkeys_challenge_request, + create_passkeys_challenge_request=create_passkeys_challenge_request, ) def create_with_http_info( - self, create_passkeys_challenge_request: CreatePasskeysChallengeRequest + self, + create_passkeys_challenge_request: Union[ + CreatePasskeysChallengeRequest, object + ] = values.unset, ) -> ApiResponse: """ Create the NewChallengeInstance with HTTP info @@ -158,11 +163,14 @@ def create_with_http_info( :returns: ApiResponse with instance, status code, and headers """ return self._proxy.create_with_http_info( - create_passkeys_challenge_request, + create_passkeys_challenge_request=create_passkeys_challenge_request, ) async def create_with_http_info_async( - self, create_passkeys_challenge_request: CreatePasskeysChallengeRequest + self, + create_passkeys_challenge_request: Union[ + CreatePasskeysChallengeRequest, object + ] = values.unset, ) -> ApiResponse: """ Asynchronous coroutine to create the NewChallengeInstance with HTTP info @@ -172,7 +180,7 @@ async def create_with_http_info_async( :returns: ApiResponse with instance, status code, and headers """ return await self._proxy.create_with_http_info_async( - create_passkeys_challenge_request, + create_passkeys_challenge_request=create_passkeys_challenge_request, ) def __repr__(self) -> str: @@ -222,7 +230,10 @@ def __init__(self, version: Version, service_sid: str): ) def _create( - self, create_passkeys_challenge_request: CreatePasskeysChallengeRequest + self, + create_passkeys_challenge_request: Union[ + CreatePasskeysChallengeRequest, object + ] = values.unset, ) -> tuple: """ Internal helper for create operation @@ -243,7 +254,10 @@ def _create( ) def create( - self, create_passkeys_challenge_request: CreatePasskeysChallengeRequest + self, + create_passkeys_challenge_request: Union[ + CreatePasskeysChallengeRequest, object + ] = values.unset, ) -> NewChallengeInstance: """ Create the NewChallengeInstance @@ -260,7 +274,10 @@ def create( ) def create_with_http_info( - self, create_passkeys_challenge_request: CreatePasskeysChallengeRequest + self, + create_passkeys_challenge_request: Union[ + CreatePasskeysChallengeRequest, object + ] = values.unset, ) -> ApiResponse: """ Create the NewChallengeInstance and return response metadata @@ -278,7 +295,10 @@ def create_with_http_info( return ApiResponse(data=instance, status_code=status_code, headers=headers) async def _create_async( - self, create_passkeys_challenge_request: CreatePasskeysChallengeRequest + self, + create_passkeys_challenge_request: Union[ + CreatePasskeysChallengeRequest, object + ] = values.unset, ) -> tuple: """ Internal async helper for create operation @@ -299,7 +319,10 @@ async def _create_async( ) async def create_async( - self, create_passkeys_challenge_request: CreatePasskeysChallengeRequest + self, + create_passkeys_challenge_request: Union[ + CreatePasskeysChallengeRequest, object + ] = values.unset, ) -> NewChallengeInstance: """ Asynchronous coroutine to create the NewChallengeInstance @@ -316,7 +339,10 @@ async def create_async( ) async def create_with_http_info_async( - self, create_passkeys_challenge_request: CreatePasskeysChallengeRequest + self, + create_passkeys_challenge_request: Union[ + CreatePasskeysChallengeRequest, object + ] = values.unset, ) -> ApiResponse: """ Asynchronous coroutine to create the NewChallengeInstance and return response metadata diff --git a/twilio/rest/verify/v2/service/new_factor.py b/twilio/rest/verify/v2/service/new_factor.py index b5595bca5..de42d178d 100644 --- a/twilio/rest/verify/v2/service/new_factor.py +++ b/twilio/rest/verify/v2/service/new_factor.py @@ -37,7 +37,13 @@ def __init__(self, payload: Dict[str, Any]): self.identity: Optional[str] = payload.get("identity") self.config: Optional[ NewFactorList.CreateNewPasskeysFactorRequestConfig - ] = payload.get("config") + ] = ( + NewFactorList.CreateNewPasskeysFactorRequestConfig( + payload.get("config") + ) + if payload.get("config") is not None + else None + ) def to_dict(self): return { @@ -58,16 +64,20 @@ def __init__(self, payload: Dict[str, Any]): self.relying_party: Optional[ NewFactorList.CreateNewPasskeysFactorRequestConfigRelyingParty - ] = payload.get("relying_party") - self.authenticator_attachment: Optional["NewFactorInstance.str"] = ( - payload.get("authenticator_attachment") + ] = ( + NewFactorList.CreateNewPasskeysFactorRequestConfigRelyingParty( + payload.get("relying_party") + ) + if payload.get("relying_party") is not None + else None ) - self.discoverable_credentials: Optional["NewFactorInstance.str"] = ( - payload.get("discoverable_credentials") + self.authenticator_attachment: Optional[str] = payload.get( + "authenticator_attachment" ) - self.user_verification: Optional["NewFactorInstance.str"] = payload.get( - "user_verification" + self.discoverable_credentials: Optional[str] = payload.get( + "discoverable_credentials" ) + self.user_verification: Optional[str] = payload.get("user_verification") def to_dict(self): return { @@ -136,8 +146,8 @@ def __init__(self, version: Version, payload: Dict[str, Any], service_sid: str): payload.get("date_updated") ) self.friendly_name: Optional[str] = payload.get("friendly_name") - self.status: Optional["NewFactorInstance.str"] = payload.get("status") - self.factor_type: Optional["NewFactorInstance.str"] = payload.get("factor_type") + self.status: Optional[str] = payload.get("status") + self.factor_type: Optional[str] = payload.get("factor_type") self.config: Optional[Dict[str, object]] = payload.get("config") self.metadata: Optional[Dict[str, object]] = payload.get("metadata") self.url: Optional[str] = payload.get("url") @@ -171,7 +181,13 @@ def __init__(self, payload: Dict[str, Any]): self.identity: Optional[str] = payload.get("identity") self.config: Optional[ NewFactorList.CreateNewPasskeysFactorRequestConfig - ] = payload.get("config") + ] = ( + NewFactorList.CreateNewPasskeysFactorRequestConfig( + payload.get("config") + ) + if payload.get("config") is not None + else None + ) def to_dict(self): return { @@ -192,16 +208,20 @@ def __init__(self, payload: Dict[str, Any]): self.relying_party: Optional[ NewFactorList.CreateNewPasskeysFactorRequestConfigRelyingParty - ] = payload.get("relying_party") - self.authenticator_attachment: Optional["NewFactorInstance.str"] = ( - payload.get("authenticator_attachment") + ] = ( + NewFactorList.CreateNewPasskeysFactorRequestConfigRelyingParty( + payload.get("relying_party") + ) + if payload.get("relying_party") is not None + else None ) - self.discoverable_credentials: Optional["NewFactorInstance.str"] = ( - payload.get("discoverable_credentials") + self.authenticator_attachment: Optional[str] = payload.get( + "authenticator_attachment" ) - self.user_verification: Optional["NewFactorInstance.str"] = payload.get( - "user_verification" + self.discoverable_credentials: Optional[str] = payload.get( + "discoverable_credentials" ) + self.user_verification: Optional[str] = payload.get("user_verification") def to_dict(self): return { diff --git a/twilio/rest/verify/v2/service/new_verify_factor.py b/twilio/rest/verify/v2/service/new_verify_factor.py index 703eabd3b..172d0c9e1 100644 --- a/twilio/rest/verify/v2/service/new_verify_factor.py +++ b/twilio/rest/verify/v2/service/new_verify_factor.py @@ -37,13 +37,19 @@ def __init__(self, payload: Dict[str, Any]): self.id: Optional[str] = payload.get("id") self.raw_id: Optional[str] = payload.get("rawId") - self.authenticator_attachment: Optional["NewVerifyFactorInstance.str"] = ( - payload.get("authenticatorAttachment") + self.authenticator_attachment: Optional[str] = payload.get( + "authenticatorAttachment" ) - self.type: Optional["NewVerifyFactorInstance.str"] = payload.get("type") + self.type: Optional[str] = payload.get("type") self.response: Optional[ NewVerifyFactorList.VerifyPasskeysFactorRequestResponse - ] = payload.get("response") + ] = ( + NewVerifyFactorList.VerifyPasskeysFactorRequestResponse( + payload.get("response") + ) + if payload.get("response") is not None + else None + ) def to_dict(self): return { @@ -67,7 +73,7 @@ def __init__(self, payload: Dict[str, Any]): self.attestation_object: Optional[str] = payload.get("attestationObject") self.client_data_json: Optional[str] = payload.get("clientDataJSON") - self.transports: Optional[List[Enumstr]] = payload.get("transports") + self.transports: Optional[List[str]] = payload.get("transports") def to_dict(self): return { @@ -107,10 +113,8 @@ def __init__(self, version: Version, payload: Dict[str, Any], service_sid: str): payload.get("date_updated") ) self.friendly_name: Optional[str] = payload.get("friendly_name") - self.status: Optional["NewVerifyFactorInstance.str"] = payload.get("status") - self.factor_type: Optional["NewVerifyFactorInstance.str"] = payload.get( - "factor_type" - ) + self.status: Optional[str] = payload.get("status") + self.factor_type: Optional[str] = payload.get("factor_type") self.config: Optional[Dict[str, object]] = payload.get("config") self.metadata: Optional[Dict[str, object]] = payload.get("metadata") self.url: Optional[str] = payload.get("url") @@ -144,13 +148,19 @@ def __init__(self, payload: Dict[str, Any]): self.id: Optional[str] = payload.get("id") self.raw_id: Optional[str] = payload.get("rawId") - self.authenticator_attachment: Optional["NewVerifyFactorInstance.str"] = ( - payload.get("authenticatorAttachment") + self.authenticator_attachment: Optional[str] = payload.get( + "authenticatorAttachment" ) - self.type: Optional["NewVerifyFactorInstance.str"] = payload.get("type") + self.type: Optional[str] = payload.get("type") self.response: Optional[ NewVerifyFactorList.VerifyPasskeysFactorRequestResponse - ] = payload.get("response") + ] = ( + NewVerifyFactorList.VerifyPasskeysFactorRequestResponse( + payload.get("response") + ) + if payload.get("response") is not None + else None + ) def to_dict(self): return { @@ -174,7 +184,7 @@ def __init__(self, payload: Dict[str, Any]): self.attestation_object: Optional[str] = payload.get("attestationObject") self.client_data_json: Optional[str] = payload.get("clientDataJSON") - self.transports: Optional[List[Enumstr]] = payload.get("transports") + self.transports: Optional[List[str]] = payload.get("transports") def to_dict(self): return { diff --git a/twilio/rest/verify/v2/service/verification.py b/twilio/rest/verify/v2/service/verification.py index 88ae5cb75..08df14bce 100644 --- a/twilio/rest/verify/v2/service/verification.py +++ b/twilio/rest/verify/v2/service/verification.py @@ -76,9 +76,9 @@ def __init__( self.lookup: Optional[Dict[str, object]] = payload.get("lookup") self.amount: Optional[str] = payload.get("amount") self.payee: Optional[str] = payload.get("payee") - self.send_code_attempts: Optional[List[Dict[str, object]]] = payload.get( - "send_code_attempts" - ) + self.send_code_attempts: Optional[ + List[Dict[str, Dict[str, Dict[str, object]]]] + ] = payload.get("send_code_attempts") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) @@ -488,6 +488,7 @@ def _create( app_hash: Union[str, object] = values.unset, template_sid: Union[str, object] = values.unset, template_custom_substitutions: Union[str, object] = values.unset, + templates: Union[str, object] = values.unset, device_ip: Union[str, object] = values.unset, enable_sna_client_token: Union[bool, object] = values.unset, risk_check: Union["VerificationInstance.RiskCheck", object] = values.unset, @@ -516,6 +517,7 @@ def _create( "AppHash": app_hash, "TemplateSid": template_sid, "TemplateCustomSubstitutions": template_custom_substitutions, + "Templates": templates, "DeviceIp": device_ip, "EnableSnaClientToken": serialize.boolean_to_string( enable_sna_client_token @@ -550,6 +552,7 @@ def create( app_hash: Union[str, object] = values.unset, template_sid: Union[str, object] = values.unset, template_custom_substitutions: Union[str, object] = values.unset, + templates: Union[str, object] = values.unset, device_ip: Union[str, object] = values.unset, enable_sna_client_token: Union[bool, object] = values.unset, risk_check: Union["VerificationInstance.RiskCheck", object] = values.unset, @@ -570,8 +573,9 @@ def create( :param rate_limits: The custom key-value pairs of Programmable Rate Limits. Keys correspond to `unique_name` fields defined when [creating your Rate Limit](https://www.twilio.com/docs/verify/api/service-rate-limits). Associated value pairs represent values in the request that you are rate limiting on. You may include multiple Rate Limit values in each request. :param channel_configuration: [`email`](https://www.twilio.com/docs/verify/email) channel configuration in json format. The fields 'from' and 'from_name' are optional but if included the 'from' field must have a valid email address. :param app_hash: Your [App Hash](https://developers.google.com/identity/sms-retriever/verify#computing_your_apps_hash_string) to be appended at the end of your verification SMS body. Applies only to SMS. Example SMS body: `<#> Your AppName verification code is: 1234 He42w354ol9`. - :param template_sid: The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. + :param template_sid: The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. If the `Templates` parameter is also provided, `Templates` takes precedence over this parameter. :param template_custom_substitutions: A stringified JSON object in which the keys are the template's special variables and the values are the variables substitutions. + :param templates: A stringified JSON array of template entries, ordered by preference. Each entry is an object with the following fields: `sid` (string, required, matching `^HJ[0-9a-fA-F]{32}$`) — the SID of the message [template](https://www.twilio.com/docs/verify/api/templates) to apply; and `substitutions` (object, optional) — a key-value map in which the keys are the template's special variables and the values are their substitution values. The array may contain up to 10 entries. If provided, `Templates` takes precedence over `TemplateSid` and `TemplateCustomSubstitutions`. :param device_ip: Strongly encouraged if using the auto channel. The IP address of the client's device. If provided, it has to be a valid IPv4 or IPv6 address. :param enable_sna_client_token: An optional Boolean value to indicate the requirement of sna client token in the SNA URL invocation response for added security. This token must match in the Verification Check request to confirm phone number verification. :param risk_check: @@ -594,6 +598,7 @@ def create( app_hash=app_hash, template_sid=template_sid, template_custom_substitutions=template_custom_substitutions, + templates=templates, device_ip=device_ip, enable_sna_client_token=enable_sna_client_token, risk_check=risk_check, @@ -619,6 +624,7 @@ def create_with_http_info( app_hash: Union[str, object] = values.unset, template_sid: Union[str, object] = values.unset, template_custom_substitutions: Union[str, object] = values.unset, + templates: Union[str, object] = values.unset, device_ip: Union[str, object] = values.unset, enable_sna_client_token: Union[bool, object] = values.unset, risk_check: Union["VerificationInstance.RiskCheck", object] = values.unset, @@ -639,8 +645,9 @@ def create_with_http_info( :param rate_limits: The custom key-value pairs of Programmable Rate Limits. Keys correspond to `unique_name` fields defined when [creating your Rate Limit](https://www.twilio.com/docs/verify/api/service-rate-limits). Associated value pairs represent values in the request that you are rate limiting on. You may include multiple Rate Limit values in each request. :param channel_configuration: [`email`](https://www.twilio.com/docs/verify/email) channel configuration in json format. The fields 'from' and 'from_name' are optional but if included the 'from' field must have a valid email address. :param app_hash: Your [App Hash](https://developers.google.com/identity/sms-retriever/verify#computing_your_apps_hash_string) to be appended at the end of your verification SMS body. Applies only to SMS. Example SMS body: `<#> Your AppName verification code is: 1234 He42w354ol9`. - :param template_sid: The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. + :param template_sid: The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. If the `Templates` parameter is also provided, `Templates` takes precedence over this parameter. :param template_custom_substitutions: A stringified JSON object in which the keys are the template's special variables and the values are the variables substitutions. + :param templates: A stringified JSON array of template entries, ordered by preference. Each entry is an object with the following fields: `sid` (string, required, matching `^HJ[0-9a-fA-F]{32}$`) — the SID of the message [template](https://www.twilio.com/docs/verify/api/templates) to apply; and `substitutions` (object, optional) — a key-value map in which the keys are the template's special variables and the values are their substitution values. The array may contain up to 10 entries. If provided, `Templates` takes precedence over `TemplateSid` and `TemplateCustomSubstitutions`. :param device_ip: Strongly encouraged if using the auto channel. The IP address of the client's device. If provided, it has to be a valid IPv4 or IPv6 address. :param enable_sna_client_token: An optional Boolean value to indicate the requirement of sna client token in the SNA URL invocation response for added security. This token must match in the Verification Check request to confirm phone number verification. :param risk_check: @@ -663,6 +670,7 @@ def create_with_http_info( app_hash=app_hash, template_sid=template_sid, template_custom_substitutions=template_custom_substitutions, + templates=templates, device_ip=device_ip, enable_sna_client_token=enable_sna_client_token, risk_check=risk_check, @@ -689,6 +697,7 @@ async def _create_async( app_hash: Union[str, object] = values.unset, template_sid: Union[str, object] = values.unset, template_custom_substitutions: Union[str, object] = values.unset, + templates: Union[str, object] = values.unset, device_ip: Union[str, object] = values.unset, enable_sna_client_token: Union[bool, object] = values.unset, risk_check: Union["VerificationInstance.RiskCheck", object] = values.unset, @@ -717,6 +726,7 @@ async def _create_async( "AppHash": app_hash, "TemplateSid": template_sid, "TemplateCustomSubstitutions": template_custom_substitutions, + "Templates": templates, "DeviceIp": device_ip, "EnableSnaClientToken": serialize.boolean_to_string( enable_sna_client_token @@ -751,6 +761,7 @@ async def create_async( app_hash: Union[str, object] = values.unset, template_sid: Union[str, object] = values.unset, template_custom_substitutions: Union[str, object] = values.unset, + templates: Union[str, object] = values.unset, device_ip: Union[str, object] = values.unset, enable_sna_client_token: Union[bool, object] = values.unset, risk_check: Union["VerificationInstance.RiskCheck", object] = values.unset, @@ -771,8 +782,9 @@ async def create_async( :param rate_limits: The custom key-value pairs of Programmable Rate Limits. Keys correspond to `unique_name` fields defined when [creating your Rate Limit](https://www.twilio.com/docs/verify/api/service-rate-limits). Associated value pairs represent values in the request that you are rate limiting on. You may include multiple Rate Limit values in each request. :param channel_configuration: [`email`](https://www.twilio.com/docs/verify/email) channel configuration in json format. The fields 'from' and 'from_name' are optional but if included the 'from' field must have a valid email address. :param app_hash: Your [App Hash](https://developers.google.com/identity/sms-retriever/verify#computing_your_apps_hash_string) to be appended at the end of your verification SMS body. Applies only to SMS. Example SMS body: `<#> Your AppName verification code is: 1234 He42w354ol9`. - :param template_sid: The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. + :param template_sid: The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. If the `Templates` parameter is also provided, `Templates` takes precedence over this parameter. :param template_custom_substitutions: A stringified JSON object in which the keys are the template's special variables and the values are the variables substitutions. + :param templates: A stringified JSON array of template entries, ordered by preference. Each entry is an object with the following fields: `sid` (string, required, matching `^HJ[0-9a-fA-F]{32}$`) — the SID of the message [template](https://www.twilio.com/docs/verify/api/templates) to apply; and `substitutions` (object, optional) — a key-value map in which the keys are the template's special variables and the values are their substitution values. The array may contain up to 10 entries. If provided, `Templates` takes precedence over `TemplateSid` and `TemplateCustomSubstitutions`. :param device_ip: Strongly encouraged if using the auto channel. The IP address of the client's device. If provided, it has to be a valid IPv4 or IPv6 address. :param enable_sna_client_token: An optional Boolean value to indicate the requirement of sna client token in the SNA URL invocation response for added security. This token must match in the Verification Check request to confirm phone number verification. :param risk_check: @@ -795,6 +807,7 @@ async def create_async( app_hash=app_hash, template_sid=template_sid, template_custom_substitutions=template_custom_substitutions, + templates=templates, device_ip=device_ip, enable_sna_client_token=enable_sna_client_token, risk_check=risk_check, @@ -820,6 +833,7 @@ async def create_with_http_info_async( app_hash: Union[str, object] = values.unset, template_sid: Union[str, object] = values.unset, template_custom_substitutions: Union[str, object] = values.unset, + templates: Union[str, object] = values.unset, device_ip: Union[str, object] = values.unset, enable_sna_client_token: Union[bool, object] = values.unset, risk_check: Union["VerificationInstance.RiskCheck", object] = values.unset, @@ -840,8 +854,9 @@ async def create_with_http_info_async( :param rate_limits: The custom key-value pairs of Programmable Rate Limits. Keys correspond to `unique_name` fields defined when [creating your Rate Limit](https://www.twilio.com/docs/verify/api/service-rate-limits). Associated value pairs represent values in the request that you are rate limiting on. You may include multiple Rate Limit values in each request. :param channel_configuration: [`email`](https://www.twilio.com/docs/verify/email) channel configuration in json format. The fields 'from' and 'from_name' are optional but if included the 'from' field must have a valid email address. :param app_hash: Your [App Hash](https://developers.google.com/identity/sms-retriever/verify#computing_your_apps_hash_string) to be appended at the end of your verification SMS body. Applies only to SMS. Example SMS body: `<#> Your AppName verification code is: 1234 He42w354ol9`. - :param template_sid: The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. + :param template_sid: The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. If the `Templates` parameter is also provided, `Templates` takes precedence over this parameter. :param template_custom_substitutions: A stringified JSON object in which the keys are the template's special variables and the values are the variables substitutions. + :param templates: A stringified JSON array of template entries, ordered by preference. Each entry is an object with the following fields: `sid` (string, required, matching `^HJ[0-9a-fA-F]{32}$`) — the SID of the message [template](https://www.twilio.com/docs/verify/api/templates) to apply; and `substitutions` (object, optional) — a key-value map in which the keys are the template's special variables and the values are their substitution values. The array may contain up to 10 entries. If provided, `Templates` takes precedence over `TemplateSid` and `TemplateCustomSubstitutions`. :param device_ip: Strongly encouraged if using the auto channel. The IP address of the client's device. If provided, it has to be a valid IPv4 or IPv6 address. :param enable_sna_client_token: An optional Boolean value to indicate the requirement of sna client token in the SNA URL invocation response for added security. This token must match in the Verification Check request to confirm phone number verification. :param risk_check: @@ -864,6 +879,7 @@ async def create_with_http_info_async( app_hash=app_hash, template_sid=template_sid, template_custom_substitutions=template_custom_substitutions, + templates=templates, device_ip=device_ip, enable_sna_client_token=enable_sna_client_token, risk_check=risk_check, diff --git a/twilio/rest/voice/v2/recording.py b/twilio/rest/voice/v2/recording.py index 0ae6ac1ac..9f4ea179f 100644 --- a/twilio/rest/voice/v2/recording.py +++ b/twilio/rest/voice/v2/recording.py @@ -33,9 +33,9 @@ class VoiceV2ConfigurationRecordingCompositionPolicy(object): def __init__(self, payload: Dict[str, Any]): - self.channels: Optional["RecordingInstance.str"] = payload.get("channels") - self.trim: Optional["RecordingInstance.str"] = payload.get("trim") - self.track: Optional["RecordingInstance.str"] = payload.get("track") + self.channels: Optional[str] = payload.get("channels") + self.trim: Optional[str] = payload.get("trim") + self.track: Optional[str] = payload.get("track") def to_dict(self): return { @@ -55,21 +55,48 @@ class VoiceV2ConfigurationRecordingConfiguration(object): def __init__(self, payload: Dict[str, Any]): - self.configuration_type: Optional["RecordingInstance.str"] = payload.get( - "configurationType" - ) + self.configuration_type: Optional[str] = payload.get("configurationType") self.composition_policy: Optional[ RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy - ] = payload.get("compositionPolicy") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy( + payload.get("compositionPolicy") + ) + if payload.get("compositionPolicy") is not None + else None + ) self.call_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback - ] = payload.get("callRecordingStatusCallback") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingStatusCallback( + payload.get("callRecordingStatusCallback") + ) + if payload.get("callRecordingStatusCallback") is not None + else None + ) self.conference_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback - ] = payload.get("conferenceRecordingStatusCallback") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingStatusCallback( + payload.get("conferenceRecordingStatusCallback") + ) + if payload.get("conferenceRecordingStatusCallback") is not None + else None + ) self.features: Optional[ List[RecordingList.VoiceV2ConfigurationRecordingFeature] - ] = payload.get("features") + ] = ( + [ + ( + RecordingList.VoiceV2ConfigurationRecordingFeature(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("features") + ] + if payload.get("features") is not None + else None + ) def to_dict(self): return { @@ -105,7 +132,7 @@ class VoiceV2ConfigurationRecordingFeature(object): def __init__(self, payload: Dict[str, Any]): - self.type: Optional["RecordingInstance.str"] = payload.get("type") + self.type: Optional[str] = payload.get("type") self.feature_id: Optional[str] = payload.get("featureId") self.description: Optional[str] = payload.get("description") @@ -129,7 +156,13 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.configuration: Optional[ RecordingList.VoiceV2ConfigurationRecordingConfiguration - ] = payload.get("configuration") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) def to_dict(self): return { @@ -152,8 +185,8 @@ class VoiceV2ConfigurationRecordingStatusCallback(object): def __init__(self, payload: Dict[str, Any]): self.url: Optional[str] = payload.get("url") - self.method: Optional["RecordingInstance.str"] = payload.get("method") - self.events: Optional[List[Enumstr]] = payload.get("events") + self.method: Optional[str] = payload.get("method") + self.events: Optional[List[str]] = payload.get("events") def to_dict(self): return { @@ -382,9 +415,9 @@ class VoiceV2ConfigurationRecordingCompositionPolicy(object): def __init__(self, payload: Dict[str, Any]): - self.channels: Optional["RecordingInstance.str"] = payload.get("channels") - self.trim: Optional["RecordingInstance.str"] = payload.get("trim") - self.track: Optional["RecordingInstance.str"] = payload.get("track") + self.channels: Optional[str] = payload.get("channels") + self.trim: Optional[str] = payload.get("trim") + self.track: Optional[str] = payload.get("track") def to_dict(self): return { @@ -404,21 +437,48 @@ class VoiceV2ConfigurationRecordingConfiguration(object): def __init__(self, payload: Dict[str, Any]): - self.configuration_type: Optional["RecordingInstance.str"] = payload.get( - "configurationType" - ) + self.configuration_type: Optional[str] = payload.get("configurationType") self.composition_policy: Optional[ RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy - ] = payload.get("compositionPolicy") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy( + payload.get("compositionPolicy") + ) + if payload.get("compositionPolicy") is not None + else None + ) self.call_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback - ] = payload.get("callRecordingStatusCallback") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingStatusCallback( + payload.get("callRecordingStatusCallback") + ) + if payload.get("callRecordingStatusCallback") is not None + else None + ) self.conference_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback - ] = payload.get("conferenceRecordingStatusCallback") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingStatusCallback( + payload.get("conferenceRecordingStatusCallback") + ) + if payload.get("conferenceRecordingStatusCallback") is not None + else None + ) self.features: Optional[ List[RecordingList.VoiceV2ConfigurationRecordingFeature] - ] = payload.get("features") + ] = ( + [ + ( + RecordingList.VoiceV2ConfigurationRecordingFeature(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("features") + ] + if payload.get("features") is not None + else None + ) def to_dict(self): return { @@ -454,7 +514,7 @@ class VoiceV2ConfigurationRecordingFeature(object): def __init__(self, payload: Dict[str, Any]): - self.type: Optional["RecordingInstance.str"] = payload.get("type") + self.type: Optional[str] = payload.get("type") self.feature_id: Optional[str] = payload.get("featureId") self.description: Optional[str] = payload.get("description") @@ -478,7 +538,13 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.configuration: Optional[ RecordingList.VoiceV2ConfigurationRecordingConfiguration - ] = payload.get("configuration") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) def to_dict(self): return { @@ -501,8 +567,8 @@ class VoiceV2ConfigurationRecordingStatusCallback(object): def __init__(self, payload: Dict[str, Any]): self.url: Optional[str] = payload.get("url") - self.method: Optional["RecordingInstance.str"] = payload.get("method") - self.events: Optional[List[Enumstr]] = payload.get("events") + self.method: Optional[str] = payload.get("method") + self.events: Optional[List[str]] = payload.get("events") def to_dict(self): return { @@ -849,9 +915,9 @@ class VoiceV2ConfigurationRecordingCompositionPolicy(object): def __init__(self, payload: Dict[str, Any]): - self.channels: Optional["RecordingInstance.str"] = payload.get("channels") - self.trim: Optional["RecordingInstance.str"] = payload.get("trim") - self.track: Optional["RecordingInstance.str"] = payload.get("track") + self.channels: Optional[str] = payload.get("channels") + self.trim: Optional[str] = payload.get("trim") + self.track: Optional[str] = payload.get("track") def to_dict(self): return { @@ -871,21 +937,48 @@ class VoiceV2ConfigurationRecordingConfiguration(object): def __init__(self, payload: Dict[str, Any]): - self.configuration_type: Optional["RecordingInstance.str"] = payload.get( - "configurationType" - ) + self.configuration_type: Optional[str] = payload.get("configurationType") self.composition_policy: Optional[ RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy - ] = payload.get("compositionPolicy") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy( + payload.get("compositionPolicy") + ) + if payload.get("compositionPolicy") is not None + else None + ) self.call_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback - ] = payload.get("callRecordingStatusCallback") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingStatusCallback( + payload.get("callRecordingStatusCallback") + ) + if payload.get("callRecordingStatusCallback") is not None + else None + ) self.conference_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback - ] = payload.get("conferenceRecordingStatusCallback") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingStatusCallback( + payload.get("conferenceRecordingStatusCallback") + ) + if payload.get("conferenceRecordingStatusCallback") is not None + else None + ) self.features: Optional[ List[RecordingList.VoiceV2ConfigurationRecordingFeature] - ] = payload.get("features") + ] = ( + [ + ( + RecordingList.VoiceV2ConfigurationRecordingFeature(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("features") + ] + if payload.get("features") is not None + else None + ) def to_dict(self): return { @@ -921,7 +1014,7 @@ class VoiceV2ConfigurationRecordingFeature(object): def __init__(self, payload: Dict[str, Any]): - self.type: Optional["RecordingInstance.str"] = payload.get("type") + self.type: Optional[str] = payload.get("type") self.feature_id: Optional[str] = payload.get("featureId") self.description: Optional[str] = payload.get("description") @@ -945,7 +1038,13 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.configuration: Optional[ RecordingList.VoiceV2ConfigurationRecordingConfiguration - ] = payload.get("configuration") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) def to_dict(self): return { @@ -968,8 +1067,8 @@ class VoiceV2ConfigurationRecordingStatusCallback(object): def __init__(self, payload: Dict[str, Any]): self.url: Optional[str] = payload.get("url") - self.method: Optional["RecordingInstance.str"] = payload.get("method") - self.events: Optional[List[Enumstr]] = payload.get("events") + self.method: Optional[str] = payload.get("method") + self.events: Optional[List[str]] = payload.get("events") def to_dict(self): return { diff --git a/twilio/rest/voice/v2/transcription.py b/twilio/rest/voice/v2/transcription.py index d76c1f421..7c8dedda3 100644 --- a/twilio/rest/voice/v2/transcription.py +++ b/twilio/rest/voice/v2/transcription.py @@ -37,9 +37,7 @@ class VoiceV2ConfigurationTranscriptionConfiguration(object): def __init__(self, payload: Dict[str, Any]): - self.configuration_type: Optional["TranscriptionInstance.str"] = ( - payload.get("configurationType") - ) + self.configuration_type: Optional[str] = payload.get("configurationType") self.transcription_engine: Optional[str] = payload.get( "transcriptionEngine" ) @@ -47,7 +45,13 @@ def __init__(self, payload: Dict[str, Any]): self.language: Optional[str] = payload.get("language") self.transcription_status_callback: Optional[ TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback - ] = payload.get("transcriptionStatusCallback") + ] = ( + TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback( + payload.get("transcriptionStatusCallback") + ) + if payload.get("transcriptionStatusCallback") is not None + else None + ) self.conversation_configuration_id: Optional[str] = payload.get( "conversationConfigurationId" ) @@ -55,7 +59,20 @@ def __init__(self, payload: Dict[str, Any]): List[ TranscriptionList.VoiceV2ConfigurationTranscriptionParticipantDefault ] - ] = payload.get("participantDefaults") + ] = ( + [ + ( + TranscriptionList.VoiceV2ConfigurationTranscriptionParticipantDefault( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("participantDefaults") + ] + if payload.get("participantDefaults") is not None + else None + ) def to_dict(self): return { @@ -88,7 +105,7 @@ class VoiceV2ConfigurationTranscriptionParticipantDefault(object): def __init__(self, payload: Dict[str, Any]): self.audio_channel_index: Optional[int] = payload.get("audioChannelIndex") - self.type: Optional["TranscriptionInstance.str"] = payload.get("type") + self.type: Optional[str] = payload.get("type") def to_dict(self): return { @@ -109,7 +126,13 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.configuration: Optional[ TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration - ] = payload.get("configuration") + ] = ( + TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) def to_dict(self): return { @@ -131,7 +154,7 @@ class VoiceV2ConfigurationTranscriptionStatusCallback(object): def __init__(self, payload: Dict[str, Any]): self.url: Optional[str] = payload.get("url") - self.method: Optional["TranscriptionInstance.str"] = payload.get("method") + self.method: Optional[str] = payload.get("method") def to_dict(self): return { @@ -363,9 +386,7 @@ class VoiceV2ConfigurationTranscriptionConfiguration(object): def __init__(self, payload: Dict[str, Any]): - self.configuration_type: Optional["TranscriptionInstance.str"] = ( - payload.get("configurationType") - ) + self.configuration_type: Optional[str] = payload.get("configurationType") self.transcription_engine: Optional[str] = payload.get( "transcriptionEngine" ) @@ -373,7 +394,13 @@ def __init__(self, payload: Dict[str, Any]): self.language: Optional[str] = payload.get("language") self.transcription_status_callback: Optional[ TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback - ] = payload.get("transcriptionStatusCallback") + ] = ( + TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback( + payload.get("transcriptionStatusCallback") + ) + if payload.get("transcriptionStatusCallback") is not None + else None + ) self.conversation_configuration_id: Optional[str] = payload.get( "conversationConfigurationId" ) @@ -381,7 +408,20 @@ def __init__(self, payload: Dict[str, Any]): List[ TranscriptionList.VoiceV2ConfigurationTranscriptionParticipantDefault ] - ] = payload.get("participantDefaults") + ] = ( + [ + ( + TranscriptionList.VoiceV2ConfigurationTranscriptionParticipantDefault( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("participantDefaults") + ] + if payload.get("participantDefaults") is not None + else None + ) def to_dict(self): return { @@ -414,7 +454,7 @@ class VoiceV2ConfigurationTranscriptionParticipantDefault(object): def __init__(self, payload: Dict[str, Any]): self.audio_channel_index: Optional[int] = payload.get("audioChannelIndex") - self.type: Optional["TranscriptionInstance.str"] = payload.get("type") + self.type: Optional[str] = payload.get("type") def to_dict(self): return { @@ -435,7 +475,13 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.configuration: Optional[ TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration - ] = payload.get("configuration") + ] = ( + TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) def to_dict(self): return { @@ -457,7 +503,7 @@ class VoiceV2ConfigurationTranscriptionStatusCallback(object): def __init__(self, payload: Dict[str, Any]): self.url: Optional[str] = payload.get("url") - self.method: Optional["TranscriptionInstance.str"] = payload.get("method") + self.method: Optional[str] = payload.get("method") def to_dict(self): return { @@ -807,9 +853,7 @@ class VoiceV2ConfigurationTranscriptionConfiguration(object): def __init__(self, payload: Dict[str, Any]): - self.configuration_type: Optional["TranscriptionInstance.str"] = ( - payload.get("configurationType") - ) + self.configuration_type: Optional[str] = payload.get("configurationType") self.transcription_engine: Optional[str] = payload.get( "transcriptionEngine" ) @@ -817,7 +861,13 @@ def __init__(self, payload: Dict[str, Any]): self.language: Optional[str] = payload.get("language") self.transcription_status_callback: Optional[ TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback - ] = payload.get("transcriptionStatusCallback") + ] = ( + TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback( + payload.get("transcriptionStatusCallback") + ) + if payload.get("transcriptionStatusCallback") is not None + else None + ) self.conversation_configuration_id: Optional[str] = payload.get( "conversationConfigurationId" ) @@ -825,7 +875,20 @@ def __init__(self, payload: Dict[str, Any]): List[ TranscriptionList.VoiceV2ConfigurationTranscriptionParticipantDefault ] - ] = payload.get("participantDefaults") + ] = ( + [ + ( + TranscriptionList.VoiceV2ConfigurationTranscriptionParticipantDefault( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("participantDefaults") + ] + if payload.get("participantDefaults") is not None + else None + ) def to_dict(self): return { @@ -858,7 +921,7 @@ class VoiceV2ConfigurationTranscriptionParticipantDefault(object): def __init__(self, payload: Dict[str, Any]): self.audio_channel_index: Optional[int] = payload.get("audioChannelIndex") - self.type: Optional["TranscriptionInstance.str"] = payload.get("type") + self.type: Optional[str] = payload.get("type") def to_dict(self): return { @@ -879,7 +942,13 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.configuration: Optional[ TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration - ] = payload.get("configuration") + ] = ( + TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) def to_dict(self): return { @@ -901,7 +970,7 @@ class VoiceV2ConfigurationTranscriptionStatusCallback(object): def __init__(self, payload: Dict[str, Any]): self.url: Optional[str] = payload.get("url") - self.method: Optional["TranscriptionInstance.str"] = payload.get("method") + self.method: Optional[str] = payload.get("method") def to_dict(self): return { diff --git a/twilio/rest/voice/v3/transcription.py b/twilio/rest/voice/v3/transcription.py index 5ade4ce6f..7d557f734 100644 --- a/twilio/rest/voice/v3/transcription.py +++ b/twilio/rest/voice/v3/transcription.py @@ -15,37 +15,76 @@ from __future__ import annotations from datetime import datetime -from typing import Any, Dict, List, Optional, Union -from twilio.base import values +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import deserialize, serialize, 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 TranscriptionInstance(InstanceResource): """ - :ivar operation_id: Unique identifier for the transcription operation. - :ivar status: Current status of the transcription operation. PENDING: accepted but not yet started. RUNNING: currently in progress. COMPLETED: successfully completed. FAILED: failed and cannot be completed. - :ivar status_url: URL to poll for the latest operation status. + :ivar id: Unique identifier for a Transcription. This is also the transcriptionId returned in the LRO 202 response. + :ivar account_id: Twilio Account SID + :ivar status: The current status of the transcription operation + :ivar transcription_configuration_id: Unique identifier for a Transcription configuration. + :ivar media_url: The third party media URL + :ivar source_id: The source ID (recording ID) - used for tracking only + :ivar audio_started_at: The call/recording start time. When the transcription was created using a sourceId, this value is inferred from the recording resource's start time. When created using a mediaUrl, this reflects the value supplied by the caller. + :ivar conversation_id: Maestro conversation ID, populated once the transcription has been stored in Maestro. + :ivar participants: Array of participants in the conversation + :ivar duration: Audio duration in seconds + :ivar resolved_configuration: + :ivar created_at: When this transcript was created + :ivar updated_at: When this transcript was last updated + :ivar url: The URL of this resource + :ivar links: Absolute URLs of resources related to this Transcription. Includes `conversation`, the Conversations API resource for this Transcription's `conversationId`, once the transcript has been stored. Omitted entirely when there is no related resource to link to. + :ivar status_url: URI to poll for operation status. Mirrors the Location response header. Provided as a body field for programmatic access by JSON-parsing clients (RFC 9110 Section 15.3.3). :ivar transcription: + :ivar operation_id: Unique identifier for the transcription operation. """ def __init__( self, version: Version, - payload: ResponseResource, + payload: Dict[str, Any], transcription_id: Optional[str] = None, ): super().__init__(version) - self.operation_id: Optional[str] = payload.get("operationId") - self.status: Optional["TranscriptionInstance.str"] = payload.get("status") - self.status_url: Optional[str] = payload.get("statusUrl") - self.transcription: Optional[VoiceV3TranscriptionTranscription] = payload.get( - "transcription" + self.id: Optional[str] = payload.get("id") + self.account_id: Optional[str] = payload.get("accountId") + self.status: Optional[str] = payload.get("status") + self.transcription_configuration_id: Optional[str] = payload.get( + "transcriptionConfigurationId" + ) + self.media_url: Optional[str] = payload.get("mediaUrl") + self.source_id: Optional[str] = payload.get("sourceId") + self.audio_started_at: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("audioStartedAt") ) + self.conversation_id: Optional[str] = payload.get("conversationId") + self.participants: Optional[List[VoiceV3TranscriptionParticipant]] = ( + payload.get("participants") + ) + self.duration: Optional[int] = deserialize.integer(payload.get("duration")) + self.resolved_configuration: Optional[ + VoiceV3TranscriptionResolvedConfiguration + ] = payload.get("resolvedConfiguration") + self.created_at: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("createdAt") + ) + self.updated_at: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("updatedAt") + ) + self.url: Optional[str] = payload.get("url") + self.links: Optional[Dict[str, object]] = payload.get("links") + self.status_url: Optional[str] = payload.get("statusUrl") + self.transcription: Optional[str] = payload.get("transcription") + self.operation_id: Optional[str] = payload.get("operationId") # Only set _solution if path params are provided (not None) if transcription_id is not None: @@ -233,6 +272,26 @@ def __repr__(self) -> str: return "".format(context) +class TranscriptionPage(TokenPagination): + + def get_instance(self, payload: Dict[str, Any]) -> TranscriptionInstance: + """ + Build an instance of TranscriptionInstance + + :param payload: Payload response from the API + """ + + return TranscriptionInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + class TranscriptionList(ListResource): class CreateV3TranscriptionsRequest(object): @@ -250,13 +309,22 @@ def __init__(self, payload: Dict[str, Any]): self.transcription_configuration_id: Optional[str] = payload.get( "transcriptionConfigurationId" ) - self.input_source: Optional["TranscriptionInstance.str"] = payload.get( - "inputSource" - ) + self.input_source: Optional[str] = payload.get("inputSource") self.source_id: Optional[str] = payload.get("sourceId") self.participants: Optional[ List[TranscriptionList.VoiceV3TranscriptionParticipant] - ] = payload.get("participants") + ] = ( + [ + ( + TranscriptionList.VoiceV3TranscriptionParticipant(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("participants") + ] + if payload.get("participants") is not None + else None + ) self.media_url: Optional[str] = payload.get("mediaUrl") self.audio_started_at: Optional[datetime] = payload.get("audioStartedAt") @@ -284,7 +352,7 @@ class VoiceV3TranscriptionParticipant(object): def __init__(self, payload: Dict[str, Any]): - self.type: Optional["TranscriptionInstance.str"] = payload.get("type") + self.type: Optional[str] = payload.get("type") self.address: Optional[str] = payload.get("address") self.name: Optional[str] = payload.get("name") self.audio_channel_index: Optional[int] = payload.get("audioChannelIndex") @@ -316,13 +384,32 @@ def __init__(self, payload: Dict[str, Any]): self.language: Optional[str] = payload.get("language") self.transcription_status_callback: Optional[ VoiceV3TranscriptionTranscriptionStatusCallback - ] = payload.get("transcriptionStatusCallback") + ] = ( + VoiceV3TranscriptionTranscriptionStatusCallback( + payload.get("transcriptionStatusCallback") + ) + if payload.get("transcriptionStatusCallback") is not None + else None + ) self.conversation_configuration_id: Optional[str] = payload.get( "conversationConfigurationId" ) self.participant_defaults: Optional[ List[VoiceV3TranscriptionResolvedConfigurationParticipantDefaults] - ] = payload.get("participantDefaults") + ] = ( + [ + ( + VoiceV3TranscriptionResolvedConfigurationParticipantDefaults( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("participantDefaults") + ] + if payload.get("participantDefaults") is not None + else None + ) def to_dict(self): return { @@ -527,6 +614,577 @@ async def create_with_http_info_async( instance = TranscriptionInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) + def stream( + self, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[TranscriptionInstance]: + """ + Streams TranscriptionInstance 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 datetime created_after: Only include transcriptions created at or after this time (inclusive) + :param datetime created_before: Only include transcriptions created strictly before this time (exclusive) + :param str language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param str source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param str status: Only include transcriptions in this status + :param str page_token: Opaque cursor for retrieving the next or previous page of results + :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( + created_after=created_after, + created_before=created_before, + language_code=language_code, + source_id=source_id, + status=status, + page_token=page_token, + page_size=limits["page_size"], + ) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[TranscriptionInstance]: + """ + Asynchronously streams TranscriptionInstance 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 datetime created_after: Only include transcriptions created at or after this time (inclusive) + :param datetime created_before: Only include transcriptions created strictly before this time (exclusive) + :param str language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param str source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param str status: Only include transcriptions in this status + :param str page_token: Opaque cursor for retrieving the next or previous page of results + :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( + created_after=created_after, + created_before=created_before, + language_code=language_code, + source_id=source_id, + status=status, + page_token=page_token, + page_size=limits["page_size"], + ) + + return self._version.stream_async(page, limits["limit"]) + + def stream_with_http_info( + self, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> tuple: + """ + Streams TranscriptionInstance and returns headers from first page + + + :param datetime created_after: Only include transcriptions created at or after this time (inclusive) + :param datetime created_before: Only include transcriptions created strictly before this time (exclusive) + :param str language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param str source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param str status: Only include transcriptions in this status + :param str page_token: Opaque cursor for retrieving the next or previous page of results + :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( + created_after=created_after, + created_before=created_before, + language_code=language_code, + source_id=source_id, + status=status, + 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, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> tuple: + """ + Asynchronously streams TranscriptionInstance and returns headers from first page + + + :param datetime created_after: Only include transcriptions created at or after this time (inclusive) + :param datetime created_before: Only include transcriptions created strictly before this time (exclusive) + :param str language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param str source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param str status: Only include transcriptions in this status + :param str page_token: Opaque cursor for retrieving the next or previous page of results + :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( + created_after=created_after, + created_before=created_before, + language_code=language_code, + source_id=source_id, + status=status, + 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, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[TranscriptionInstance]: + """ + Lists TranscriptionInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param datetime created_after: Only include transcriptions created at or after this time (inclusive) + :param datetime created_before: Only include transcriptions created strictly before this time (exclusive) + :param str language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param str source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param str status: Only include transcriptions in this status + :param str page_token: Opaque cursor for retrieving the next or previous page of results + :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( + created_after=created_after, + created_before=created_before, + language_code=language_code, + source_id=source_id, + status=status, + page_token=page_token, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[TranscriptionInstance]: + """ + Asynchronously lists TranscriptionInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param datetime created_after: Only include transcriptions created at or after this time (inclusive) + :param datetime created_before: Only include transcriptions created strictly before this time (exclusive) + :param str language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param str source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param str status: Only include transcriptions in this status + :param str page_token: Opaque cursor for retrieving the next or previous page of results + :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( + created_after=created_after, + created_before=created_before, + language_code=language_code, + source_id=source_id, + status=status, + page_token=page_token, + limit=limit, + page_size=page_size, + ) + ] + + def list_with_http_info( + self, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ApiResponse: + """ + Lists TranscriptionInstance and returns headers from first page + + + :param datetime created_after: Only include transcriptions created at or after this time (inclusive) + :param datetime created_before: Only include transcriptions created strictly before this time (exclusive) + :param str language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param str source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param str status: Only include transcriptions in this status + :param str page_token: Opaque cursor for retrieving the next or previous page of results + :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( + created_after=created_after, + created_before=created_before, + language_code=language_code, + source_id=source_id, + status=status, + 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, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ApiResponse: + """ + Asynchronously lists TranscriptionInstance and returns headers from first page + + + :param datetime created_after: Only include transcriptions created at or after this time (inclusive) + :param datetime created_before: Only include transcriptions created strictly before this time (exclusive) + :param str language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param str source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param str status: Only include transcriptions in this status + :param str page_token: Opaque cursor for retrieving the next or previous page of results + :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( + created_after=created_after, + created_before=created_before, + language_code=language_code, + source_id=source_id, + status=status, + 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, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_size: Union[int, object] = values.unset, + page_token: Union[str, object] = values.unset, + ) -> TranscriptionPage: + """ + Retrieve a single page of TranscriptionInstance records from the API. + Request is executed immediately + + :param created_after: Only include transcriptions created at or after this time (inclusive) + :param created_before: Only include transcriptions created strictly before this time (exclusive) + :param language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param status: Only include transcriptions in this status + :param page_size: Number of results per page. This endpoint caps at 100, which is lower than the shared pagination component's ceiling and matches what the service enforces. + :param page_token: Opaque cursor for retrieving the next or previous page of results + :returns: Page of TranscriptionInstance + """ + data = values.of( + { + "createdAfter": serialize.iso8601_datetime(created_after), + "createdBefore": serialize.iso8601_datetime(created_before), + "languageCode": language_code, + "sourceId": source_id, + "status": status, + "pageSize": page_size, + "pageToken": page_token, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return TranscriptionPage(self._version, response, uri=self._uri, params=data) + + async def page_async( + self, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_size: Union[int, object] = values.unset, + page_token: Union[str, object] = values.unset, + ) -> TranscriptionPage: + """ + Asynchronously retrieve a single page of TranscriptionInstance records from the API. + Request is executed immediately + + :param created_after: Only include transcriptions created at or after this time (inclusive) + :param created_before: Only include transcriptions created strictly before this time (exclusive) + :param language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param status: Only include transcriptions in this status + :param page_size: Number of results per page. This endpoint caps at 100, which is lower than the shared pagination component's ceiling and matches what the service enforces. + :param page_token: Opaque cursor for retrieving the next or previous page of results + :returns: Page of TranscriptionInstance + """ + data = values.of( + { + "createdAfter": serialize.iso8601_datetime(created_after), + "createdBefore": serialize.iso8601_datetime(created_before), + "languageCode": language_code, + "sourceId": source_id, + "status": status, + "pageSize": page_size, + "pageToken": page_token, + } + ) + + 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 TranscriptionPage(self._version, response, uri=self._uri, params=data) + + def page_with_http_info( + self, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> ApiResponse: + """ + Retrieve a single page with response metadata + + + :param created_after: Only include transcriptions created at or after this time (inclusive) + :param created_before: Only include transcriptions created strictly before this time (exclusive) + :param language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param status: Only include transcriptions in this status + :param page_token: Opaque cursor for retrieving the next or previous page of results + :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 TranscriptionPage, status code, and headers + """ + data = values.of( + { + "createdAfter": serialize.iso8601_datetime(created_after), + "createdBefore": serialize.iso8601_datetime(created_before), + "languageCode": language_code, + "sourceId": source_id, + "status": status, + "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" + + response, status_code, response_headers = self._version.page_with_response_info( + method="GET", uri=self._uri, params=data, headers=headers + ) + page = TranscriptionPage(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, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> ApiResponse: + """ + Asynchronously retrieve a single page with response metadata + + + :param created_after: Only include transcriptions created at or after this time (inclusive) + :param created_before: Only include transcriptions created strictly before this time (exclusive) + :param language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param status: Only include transcriptions in this status + :param page_token: Opaque cursor for retrieving the next or previous page of results + :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 TranscriptionPage, status code, and headers + """ + data = values.of( + { + "createdAfter": serialize.iso8601_datetime(created_after), + "createdBefore": serialize.iso8601_datetime(created_before), + "languageCode": language_code, + "sourceId": source_id, + "status": status, + "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" + + response, status_code, response_headers = ( + await self._version.page_with_response_info_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + ) + page = TranscriptionPage(self._version, response) + return ApiResponse(data=page, status_code=status_code, headers=response_headers) + + def get_page(self, target_url: str) -> TranscriptionPage: + """ + Retrieve a specific page of TranscriptionInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of TranscriptionInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return TranscriptionPage(self._version, response) + + async def get_page_async(self, target_url: str) -> TranscriptionPage: + """ + Asynchronously retrieve a specific page of TranscriptionInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of TranscriptionInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return TranscriptionPage(self._version, response) + def get(self, transcription_id: str) -> TranscriptionContext: """ Constructs a TranscriptionContext