Initial commit: Email alerts application
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from twilio.base.domain import Domain
|
||||
from twilio.rest import Client
|
||||
from twilio.rest.conversations.v1 import V1
|
||||
|
||||
|
||||
class ConversationsBase(Domain):
|
||||
def __init__(self, twilio: Client):
|
||||
"""
|
||||
Initialize the Conversations Domain
|
||||
|
||||
:returns: Domain for Conversations
|
||||
"""
|
||||
super().__init__(twilio, "https://conversations.twilio.com")
|
||||
self._v1: Optional[V1] = None
|
||||
|
||||
@property
|
||||
def v1(self) -> V1:
|
||||
"""
|
||||
:returns: Versions v1 of Conversations
|
||||
"""
|
||||
if self._v1 is None:
|
||||
self._v1 = V1(self)
|
||||
return self._v1
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations>"
|
||||
@@ -0,0 +1,87 @@
|
||||
from warnings import warn
|
||||
|
||||
from twilio.rest.conversations.ConversationsBase import ConversationsBase
|
||||
from twilio.rest.conversations.v1.address_configuration import AddressConfigurationList
|
||||
from twilio.rest.conversations.v1.configuration import ConfigurationList
|
||||
from twilio.rest.conversations.v1.conversation import ConversationList
|
||||
from twilio.rest.conversations.v1.credential import CredentialList
|
||||
from twilio.rest.conversations.v1.participant_conversation import (
|
||||
ParticipantConversationList,
|
||||
)
|
||||
from twilio.rest.conversations.v1.role import RoleList
|
||||
from twilio.rest.conversations.v1.service import ServiceList
|
||||
from twilio.rest.conversations.v1.user import UserList
|
||||
|
||||
|
||||
class Conversations(ConversationsBase):
|
||||
@property
|
||||
def configuration(self) -> ConfigurationList:
|
||||
warn(
|
||||
"configuration is deprecated. Use v1.configuration instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.configuration
|
||||
|
||||
@property
|
||||
def address_configurations(self) -> AddressConfigurationList:
|
||||
warn(
|
||||
"address_configurations is deprecated. Use v1.address_configurations instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.address_configurations
|
||||
|
||||
@property
|
||||
def conversations(self) -> ConversationList:
|
||||
warn(
|
||||
"conversations is deprecated. Use v1.conversations instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.conversations
|
||||
|
||||
@property
|
||||
def credentials(self) -> CredentialList:
|
||||
warn(
|
||||
"credentials is deprecated. Use v1.credentials instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.credentials
|
||||
|
||||
@property
|
||||
def participant_conversations(self) -> ParticipantConversationList:
|
||||
warn(
|
||||
"participant_conversations is deprecated. Use v1.participant_conversations instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.participant_conversations
|
||||
|
||||
@property
|
||||
def roles(self) -> RoleList:
|
||||
warn(
|
||||
"roles is deprecated. Use v1.roles instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.roles
|
||||
|
||||
@property
|
||||
def services(self) -> ServiceList:
|
||||
warn(
|
||||
"services is deprecated. Use v1.services instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.services
|
||||
|
||||
@property
|
||||
def users(self) -> UserList:
|
||||
warn(
|
||||
"users is deprecated. Use v1.users instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.users
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,100 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 Optional
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.domain import Domain
|
||||
from twilio.rest.conversations.v1.address_configuration import AddressConfigurationList
|
||||
from twilio.rest.conversations.v1.configuration import ConfigurationList
|
||||
from twilio.rest.conversations.v1.conversation import ConversationList
|
||||
from twilio.rest.conversations.v1.credential import CredentialList
|
||||
from twilio.rest.conversations.v1.participant_conversation import (
|
||||
ParticipantConversationList,
|
||||
)
|
||||
from twilio.rest.conversations.v1.role import RoleList
|
||||
from twilio.rest.conversations.v1.service import ServiceList
|
||||
from twilio.rest.conversations.v1.user import UserList
|
||||
|
||||
|
||||
class V1(Version):
|
||||
def __init__(self, domain: Domain):
|
||||
"""
|
||||
Initialize the V1 version of Conversations
|
||||
|
||||
:param domain: The Twilio.conversations domain
|
||||
"""
|
||||
super().__init__(domain, "v1")
|
||||
self._address_configurations: Optional[AddressConfigurationList] = None
|
||||
self._configuration: Optional[ConfigurationList] = None
|
||||
self._conversations: Optional[ConversationList] = None
|
||||
self._credentials: Optional[CredentialList] = None
|
||||
self._participant_conversations: Optional[ParticipantConversationList] = None
|
||||
self._roles: Optional[RoleList] = None
|
||||
self._services: Optional[ServiceList] = None
|
||||
self._users: Optional[UserList] = None
|
||||
|
||||
@property
|
||||
def address_configurations(self) -> AddressConfigurationList:
|
||||
if self._address_configurations is None:
|
||||
self._address_configurations = AddressConfigurationList(self)
|
||||
return self._address_configurations
|
||||
|
||||
@property
|
||||
def configuration(self) -> ConfigurationList:
|
||||
if self._configuration is None:
|
||||
self._configuration = ConfigurationList(self)
|
||||
return self._configuration
|
||||
|
||||
@property
|
||||
def conversations(self) -> ConversationList:
|
||||
if self._conversations is None:
|
||||
self._conversations = ConversationList(self)
|
||||
return self._conversations
|
||||
|
||||
@property
|
||||
def credentials(self) -> CredentialList:
|
||||
if self._credentials is None:
|
||||
self._credentials = CredentialList(self)
|
||||
return self._credentials
|
||||
|
||||
@property
|
||||
def participant_conversations(self) -> ParticipantConversationList:
|
||||
if self._participant_conversations is None:
|
||||
self._participant_conversations = ParticipantConversationList(self)
|
||||
return self._participant_conversations
|
||||
|
||||
@property
|
||||
def roles(self) -> RoleList:
|
||||
if self._roles is None:
|
||||
self._roles = RoleList(self)
|
||||
return self._roles
|
||||
|
||||
@property
|
||||
def services(self) -> ServiceList:
|
||||
if self._services is None:
|
||||
self._services = ServiceList(self)
|
||||
return self._services
|
||||
|
||||
@property
|
||||
def users(self) -> UserList:
|
||||
if self._users is None:
|
||||
self._users = UserList(self)
|
||||
return self._users
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+813
@@ -0,0 +1,813 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
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.page import Page
|
||||
|
||||
|
||||
class AddressConfigurationInstance(InstanceResource):
|
||||
class AutoCreationType(object):
|
||||
WEBHOOK = "webhook"
|
||||
STUDIO = "studio"
|
||||
DEFAULT = "default"
|
||||
|
||||
class Method(object):
|
||||
GET = "GET"
|
||||
POST = "POST"
|
||||
|
||||
class Type(object):
|
||||
SMS = "sms"
|
||||
WHATSAPP = "whatsapp"
|
||||
MESSENGER = "messenger"
|
||||
GBM = "gbm"
|
||||
EMAIL = "email"
|
||||
|
||||
"""
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) the address belongs to
|
||||
:ivar type: Type of Address, value can be `whatsapp` or `sms`.
|
||||
:ivar address: The unique address to be configured. The address can be a whatsapp address or phone number
|
||||
:ivar friendly_name: The human-readable name of this configuration, limited to 256 characters. Optional.
|
||||
:ivar auto_creation: Auto Creation configuration for the address.
|
||||
:ivar date_created: The date that this resource was created.
|
||||
:ivar date_updated: The date that this resource was last updated.
|
||||
:ivar url: An absolute API resource URL for this address configuration.
|
||||
:ivar address_country: An ISO 3166-1 alpha-2n country code which the address belongs to. This is currently only applicable to short code addresses.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.type: Optional[str] = payload.get("type")
|
||||
self.address: Optional[str] = payload.get("address")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.auto_creation: Optional[Dict[str, object]] = payload.get("auto_creation")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.address_country: Optional[str] = payload.get("address_country")
|
||||
|
||||
self._solution = {
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[AddressConfigurationContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "AddressConfigurationContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: AddressConfigurationContext for this AddressConfigurationInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = AddressConfigurationContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the AddressConfigurationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the AddressConfigurationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "AddressConfigurationInstance":
|
||||
"""
|
||||
Fetch the AddressConfigurationInstance
|
||||
|
||||
|
||||
:returns: The fetched AddressConfigurationInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "AddressConfigurationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AddressConfigurationInstance
|
||||
|
||||
|
||||
:returns: The fetched AddressConfigurationInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
auto_creation_enabled: Union[bool, object] = values.unset,
|
||||
auto_creation_type: Union[
|
||||
"AddressConfigurationInstance.AutoCreationType", object
|
||||
] = values.unset,
|
||||
auto_creation_conversation_service_sid: Union[str, object] = values.unset,
|
||||
auto_creation_webhook_url: Union[str, object] = values.unset,
|
||||
auto_creation_webhook_method: Union[
|
||||
"AddressConfigurationInstance.Method", object
|
||||
] = values.unset,
|
||||
auto_creation_webhook_filters: Union[List[str], object] = values.unset,
|
||||
auto_creation_studio_flow_sid: Union[str, object] = values.unset,
|
||||
auto_creation_studio_retry_count: Union[int, object] = values.unset,
|
||||
) -> "AddressConfigurationInstance":
|
||||
"""
|
||||
Update the AddressConfigurationInstance
|
||||
|
||||
:param friendly_name: The human-readable name of this configuration, limited to 256 characters. Optional.
|
||||
:param auto_creation_enabled: Enable/Disable auto-creating conversations for messages to this address
|
||||
:param auto_creation_type:
|
||||
:param auto_creation_conversation_service_sid: Conversation Service for the auto-created conversation. If not set, the conversation is created in the default service.
|
||||
:param auto_creation_webhook_url: For type `webhook`, the url for the webhook request.
|
||||
:param auto_creation_webhook_method:
|
||||
:param auto_creation_webhook_filters: The list of events, firing webhook event for this Conversation. Values can be any of the following: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onConversationUpdated`, `onConversationStateUpdated`, `onConversationRemoved`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`, `onDeliveryUpdated`
|
||||
:param auto_creation_studio_flow_sid: For type `studio`, the studio flow SID where the webhook should be sent to.
|
||||
:param auto_creation_studio_retry_count: For type `studio`, number of times to retry the webhook request
|
||||
|
||||
:returns: The updated AddressConfigurationInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
auto_creation_enabled=auto_creation_enabled,
|
||||
auto_creation_type=auto_creation_type,
|
||||
auto_creation_conversation_service_sid=auto_creation_conversation_service_sid,
|
||||
auto_creation_webhook_url=auto_creation_webhook_url,
|
||||
auto_creation_webhook_method=auto_creation_webhook_method,
|
||||
auto_creation_webhook_filters=auto_creation_webhook_filters,
|
||||
auto_creation_studio_flow_sid=auto_creation_studio_flow_sid,
|
||||
auto_creation_studio_retry_count=auto_creation_studio_retry_count,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
auto_creation_enabled: Union[bool, object] = values.unset,
|
||||
auto_creation_type: Union[
|
||||
"AddressConfigurationInstance.AutoCreationType", object
|
||||
] = values.unset,
|
||||
auto_creation_conversation_service_sid: Union[str, object] = values.unset,
|
||||
auto_creation_webhook_url: Union[str, object] = values.unset,
|
||||
auto_creation_webhook_method: Union[
|
||||
"AddressConfigurationInstance.Method", object
|
||||
] = values.unset,
|
||||
auto_creation_webhook_filters: Union[List[str], object] = values.unset,
|
||||
auto_creation_studio_flow_sid: Union[str, object] = values.unset,
|
||||
auto_creation_studio_retry_count: Union[int, object] = values.unset,
|
||||
) -> "AddressConfigurationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the AddressConfigurationInstance
|
||||
|
||||
:param friendly_name: The human-readable name of this configuration, limited to 256 characters. Optional.
|
||||
:param auto_creation_enabled: Enable/Disable auto-creating conversations for messages to this address
|
||||
:param auto_creation_type:
|
||||
:param auto_creation_conversation_service_sid: Conversation Service for the auto-created conversation. If not set, the conversation is created in the default service.
|
||||
:param auto_creation_webhook_url: For type `webhook`, the url for the webhook request.
|
||||
:param auto_creation_webhook_method:
|
||||
:param auto_creation_webhook_filters: The list of events, firing webhook event for this Conversation. Values can be any of the following: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onConversationUpdated`, `onConversationStateUpdated`, `onConversationRemoved`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`, `onDeliveryUpdated`
|
||||
:param auto_creation_studio_flow_sid: For type `studio`, the studio flow SID where the webhook should be sent to.
|
||||
:param auto_creation_studio_retry_count: For type `studio`, number of times to retry the webhook request
|
||||
|
||||
:returns: The updated AddressConfigurationInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
friendly_name=friendly_name,
|
||||
auto_creation_enabled=auto_creation_enabled,
|
||||
auto_creation_type=auto_creation_type,
|
||||
auto_creation_conversation_service_sid=auto_creation_conversation_service_sid,
|
||||
auto_creation_webhook_url=auto_creation_webhook_url,
|
||||
auto_creation_webhook_method=auto_creation_webhook_method,
|
||||
auto_creation_webhook_filters=auto_creation_webhook_filters,
|
||||
auto_creation_studio_flow_sid=auto_creation_studio_flow_sid,
|
||||
auto_creation_studio_retry_count=auto_creation_studio_retry_count,
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.AddressConfigurationInstance {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class AddressConfigurationContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the AddressConfigurationContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: The SID of the Address Configuration resource. This value can be either the `sid` or the `address` of the configuration
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Configuration/Addresses/{sid}".format(**self._solution)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the AddressConfigurationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the AddressConfigurationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> AddressConfigurationInstance:
|
||||
"""
|
||||
Fetch the AddressConfigurationInstance
|
||||
|
||||
|
||||
:returns: The fetched AddressConfigurationInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AddressConfigurationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> AddressConfigurationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AddressConfigurationInstance
|
||||
|
||||
|
||||
:returns: The fetched AddressConfigurationInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AddressConfigurationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
auto_creation_enabled: Union[bool, object] = values.unset,
|
||||
auto_creation_type: Union[
|
||||
"AddressConfigurationInstance.AutoCreationType", object
|
||||
] = values.unset,
|
||||
auto_creation_conversation_service_sid: Union[str, object] = values.unset,
|
||||
auto_creation_webhook_url: Union[str, object] = values.unset,
|
||||
auto_creation_webhook_method: Union[
|
||||
"AddressConfigurationInstance.Method", object
|
||||
] = values.unset,
|
||||
auto_creation_webhook_filters: Union[List[str], object] = values.unset,
|
||||
auto_creation_studio_flow_sid: Union[str, object] = values.unset,
|
||||
auto_creation_studio_retry_count: Union[int, object] = values.unset,
|
||||
) -> AddressConfigurationInstance:
|
||||
"""
|
||||
Update the AddressConfigurationInstance
|
||||
|
||||
:param friendly_name: The human-readable name of this configuration, limited to 256 characters. Optional.
|
||||
:param auto_creation_enabled: Enable/Disable auto-creating conversations for messages to this address
|
||||
:param auto_creation_type:
|
||||
:param auto_creation_conversation_service_sid: Conversation Service for the auto-created conversation. If not set, the conversation is created in the default service.
|
||||
:param auto_creation_webhook_url: For type `webhook`, the url for the webhook request.
|
||||
:param auto_creation_webhook_method:
|
||||
:param auto_creation_webhook_filters: The list of events, firing webhook event for this Conversation. Values can be any of the following: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onConversationUpdated`, `onConversationStateUpdated`, `onConversationRemoved`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`, `onDeliveryUpdated`
|
||||
:param auto_creation_studio_flow_sid: For type `studio`, the studio flow SID where the webhook should be sent to.
|
||||
:param auto_creation_studio_retry_count: For type `studio`, number of times to retry the webhook request
|
||||
|
||||
:returns: The updated AddressConfigurationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"AutoCreation.Enabled": auto_creation_enabled,
|
||||
"AutoCreation.Type": auto_creation_type,
|
||||
"AutoCreation.ConversationServiceSid": auto_creation_conversation_service_sid,
|
||||
"AutoCreation.WebhookUrl": auto_creation_webhook_url,
|
||||
"AutoCreation.WebhookMethod": auto_creation_webhook_method,
|
||||
"AutoCreation.WebhookFilters": serialize.map(
|
||||
auto_creation_webhook_filters, lambda e: e
|
||||
),
|
||||
"AutoCreation.StudioFlowSid": auto_creation_studio_flow_sid,
|
||||
"AutoCreation.StudioRetryCount": auto_creation_studio_retry_count,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AddressConfigurationInstance(
|
||||
self._version, payload, sid=self._solution["sid"]
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
auto_creation_enabled: Union[bool, object] = values.unset,
|
||||
auto_creation_type: Union[
|
||||
"AddressConfigurationInstance.AutoCreationType", object
|
||||
] = values.unset,
|
||||
auto_creation_conversation_service_sid: Union[str, object] = values.unset,
|
||||
auto_creation_webhook_url: Union[str, object] = values.unset,
|
||||
auto_creation_webhook_method: Union[
|
||||
"AddressConfigurationInstance.Method", object
|
||||
] = values.unset,
|
||||
auto_creation_webhook_filters: Union[List[str], object] = values.unset,
|
||||
auto_creation_studio_flow_sid: Union[str, object] = values.unset,
|
||||
auto_creation_studio_retry_count: Union[int, object] = values.unset,
|
||||
) -> AddressConfigurationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the AddressConfigurationInstance
|
||||
|
||||
:param friendly_name: The human-readable name of this configuration, limited to 256 characters. Optional.
|
||||
:param auto_creation_enabled: Enable/Disable auto-creating conversations for messages to this address
|
||||
:param auto_creation_type:
|
||||
:param auto_creation_conversation_service_sid: Conversation Service for the auto-created conversation. If not set, the conversation is created in the default service.
|
||||
:param auto_creation_webhook_url: For type `webhook`, the url for the webhook request.
|
||||
:param auto_creation_webhook_method:
|
||||
:param auto_creation_webhook_filters: The list of events, firing webhook event for this Conversation. Values can be any of the following: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onConversationUpdated`, `onConversationStateUpdated`, `onConversationRemoved`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`, `onDeliveryUpdated`
|
||||
:param auto_creation_studio_flow_sid: For type `studio`, the studio flow SID where the webhook should be sent to.
|
||||
:param auto_creation_studio_retry_count: For type `studio`, number of times to retry the webhook request
|
||||
|
||||
:returns: The updated AddressConfigurationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"AutoCreation.Enabled": auto_creation_enabled,
|
||||
"AutoCreation.Type": auto_creation_type,
|
||||
"AutoCreation.ConversationServiceSid": auto_creation_conversation_service_sid,
|
||||
"AutoCreation.WebhookUrl": auto_creation_webhook_url,
|
||||
"AutoCreation.WebhookMethod": auto_creation_webhook_method,
|
||||
"AutoCreation.WebhookFilters": serialize.map(
|
||||
auto_creation_webhook_filters, lambda e: e
|
||||
),
|
||||
"AutoCreation.StudioFlowSid": auto_creation_studio_flow_sid,
|
||||
"AutoCreation.StudioRetryCount": auto_creation_studio_retry_count,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AddressConfigurationInstance(
|
||||
self._version, payload, sid=self._solution["sid"]
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.AddressConfigurationContext {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class AddressConfigurationPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> AddressConfigurationInstance:
|
||||
"""
|
||||
Build an instance of AddressConfigurationInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return AddressConfigurationInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.AddressConfigurationPage>"
|
||||
|
||||
|
||||
class AddressConfigurationList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the AddressConfigurationList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/Configuration/Addresses"
|
||||
|
||||
def create(
|
||||
self,
|
||||
type: "AddressConfigurationInstance.Type",
|
||||
address: str,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
auto_creation_enabled: Union[bool, object] = values.unset,
|
||||
auto_creation_type: Union[
|
||||
"AddressConfigurationInstance.AutoCreationType", object
|
||||
] = values.unset,
|
||||
auto_creation_conversation_service_sid: Union[str, object] = values.unset,
|
||||
auto_creation_webhook_url: Union[str, object] = values.unset,
|
||||
auto_creation_webhook_method: Union[
|
||||
"AddressConfigurationInstance.Method", object
|
||||
] = values.unset,
|
||||
auto_creation_webhook_filters: Union[List[str], object] = values.unset,
|
||||
auto_creation_studio_flow_sid: Union[str, object] = values.unset,
|
||||
auto_creation_studio_retry_count: Union[int, object] = values.unset,
|
||||
address_country: Union[str, object] = values.unset,
|
||||
) -> AddressConfigurationInstance:
|
||||
"""
|
||||
Create the AddressConfigurationInstance
|
||||
|
||||
:param type:
|
||||
:param address: The unique address to be configured. The address can be a whatsapp address or phone number
|
||||
:param friendly_name: The human-readable name of this configuration, limited to 256 characters. Optional.
|
||||
:param auto_creation_enabled: Enable/Disable auto-creating conversations for messages to this address
|
||||
:param auto_creation_type:
|
||||
:param auto_creation_conversation_service_sid: Conversation Service for the auto-created conversation. If not set, the conversation is created in the default service.
|
||||
:param auto_creation_webhook_url: For type `webhook`, the url for the webhook request.
|
||||
:param auto_creation_webhook_method:
|
||||
:param auto_creation_webhook_filters: The list of events, firing webhook event for this Conversation. Values can be any of the following: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onConversationUpdated`, `onConversationStateUpdated`, `onConversationRemoved`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`, `onDeliveryUpdated`
|
||||
:param auto_creation_studio_flow_sid: For type `studio`, the studio flow SID where the webhook should be sent to.
|
||||
:param auto_creation_studio_retry_count: For type `studio`, number of times to retry the webhook request
|
||||
:param address_country: An ISO 3166-1 alpha-2n country code which the address belongs to. This is currently only applicable to short code addresses.
|
||||
|
||||
:returns: The created AddressConfigurationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Type": type,
|
||||
"Address": address,
|
||||
"FriendlyName": friendly_name,
|
||||
"AutoCreation.Enabled": auto_creation_enabled,
|
||||
"AutoCreation.Type": auto_creation_type,
|
||||
"AutoCreation.ConversationServiceSid": auto_creation_conversation_service_sid,
|
||||
"AutoCreation.WebhookUrl": auto_creation_webhook_url,
|
||||
"AutoCreation.WebhookMethod": auto_creation_webhook_method,
|
||||
"AutoCreation.WebhookFilters": serialize.map(
|
||||
auto_creation_webhook_filters, lambda e: e
|
||||
),
|
||||
"AutoCreation.StudioFlowSid": auto_creation_studio_flow_sid,
|
||||
"AutoCreation.StudioRetryCount": auto_creation_studio_retry_count,
|
||||
"AddressCountry": address_country,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AddressConfigurationInstance(self._version, payload)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
type: "AddressConfigurationInstance.Type",
|
||||
address: str,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
auto_creation_enabled: Union[bool, object] = values.unset,
|
||||
auto_creation_type: Union[
|
||||
"AddressConfigurationInstance.AutoCreationType", object
|
||||
] = values.unset,
|
||||
auto_creation_conversation_service_sid: Union[str, object] = values.unset,
|
||||
auto_creation_webhook_url: Union[str, object] = values.unset,
|
||||
auto_creation_webhook_method: Union[
|
||||
"AddressConfigurationInstance.Method", object
|
||||
] = values.unset,
|
||||
auto_creation_webhook_filters: Union[List[str], object] = values.unset,
|
||||
auto_creation_studio_flow_sid: Union[str, object] = values.unset,
|
||||
auto_creation_studio_retry_count: Union[int, object] = values.unset,
|
||||
address_country: Union[str, object] = values.unset,
|
||||
) -> AddressConfigurationInstance:
|
||||
"""
|
||||
Asynchronously create the AddressConfigurationInstance
|
||||
|
||||
:param type:
|
||||
:param address: The unique address to be configured. The address can be a whatsapp address or phone number
|
||||
:param friendly_name: The human-readable name of this configuration, limited to 256 characters. Optional.
|
||||
:param auto_creation_enabled: Enable/Disable auto-creating conversations for messages to this address
|
||||
:param auto_creation_type:
|
||||
:param auto_creation_conversation_service_sid: Conversation Service for the auto-created conversation. If not set, the conversation is created in the default service.
|
||||
:param auto_creation_webhook_url: For type `webhook`, the url for the webhook request.
|
||||
:param auto_creation_webhook_method:
|
||||
:param auto_creation_webhook_filters: The list of events, firing webhook event for this Conversation. Values can be any of the following: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onConversationUpdated`, `onConversationStateUpdated`, `onConversationRemoved`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`, `onDeliveryUpdated`
|
||||
:param auto_creation_studio_flow_sid: For type `studio`, the studio flow SID where the webhook should be sent to.
|
||||
:param auto_creation_studio_retry_count: For type `studio`, number of times to retry the webhook request
|
||||
:param address_country: An ISO 3166-1 alpha-2n country code which the address belongs to. This is currently only applicable to short code addresses.
|
||||
|
||||
:returns: The created AddressConfigurationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Type": type,
|
||||
"Address": address,
|
||||
"FriendlyName": friendly_name,
|
||||
"AutoCreation.Enabled": auto_creation_enabled,
|
||||
"AutoCreation.Type": auto_creation_type,
|
||||
"AutoCreation.ConversationServiceSid": auto_creation_conversation_service_sid,
|
||||
"AutoCreation.WebhookUrl": auto_creation_webhook_url,
|
||||
"AutoCreation.WebhookMethod": auto_creation_webhook_method,
|
||||
"AutoCreation.WebhookFilters": serialize.map(
|
||||
auto_creation_webhook_filters, lambda e: e
|
||||
),
|
||||
"AutoCreation.StudioFlowSid": auto_creation_studio_flow_sid,
|
||||
"AutoCreation.StudioRetryCount": auto_creation_studio_retry_count,
|
||||
"AddressCountry": address_country,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AddressConfigurationInstance(self._version, payload)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
type: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[AddressConfigurationInstance]:
|
||||
"""
|
||||
Streams AddressConfigurationInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str type: Filter the address configurations by its type. This value can be one of: `whatsapp`, `sms`.
|
||||
: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(type=type, page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
type: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[AddressConfigurationInstance]:
|
||||
"""
|
||||
Asynchronously streams AddressConfigurationInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str type: Filter the address configurations by its type. This value can be one of: `whatsapp`, `sms`.
|
||||
: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(type=type, page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
type: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AddressConfigurationInstance]:
|
||||
"""
|
||||
Lists AddressConfigurationInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str type: Filter the address configurations by its type. This value can be one of: `whatsapp`, `sms`.
|
||||
: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(
|
||||
type=type,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
type: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AddressConfigurationInstance]:
|
||||
"""
|
||||
Asynchronously lists AddressConfigurationInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str type: Filter the address configurations by its type. This value can be one of: `whatsapp`, `sms`.
|
||||
: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(
|
||||
type=type,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
type: 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,
|
||||
) -> AddressConfigurationPage:
|
||||
"""
|
||||
Retrieve a single page of AddressConfigurationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param type: Filter the address configurations by its type. This value can be one of: `whatsapp`, `sms`.
|
||||
: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: Page of AddressConfigurationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Type": type,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return AddressConfigurationPage(self._version, response)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
type: 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,
|
||||
) -> AddressConfigurationPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of AddressConfigurationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param type: Filter the address configurations by its type. This value can be one of: `whatsapp`, `sms`.
|
||||
: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: Page of AddressConfigurationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Type": type,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return AddressConfigurationPage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> AddressConfigurationPage:
|
||||
"""
|
||||
Retrieve a specific page of AddressConfigurationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AddressConfigurationInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return AddressConfigurationPage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> AddressConfigurationPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of AddressConfigurationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AddressConfigurationInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return AddressConfigurationPage(self._version, response)
|
||||
|
||||
def get(self, sid: str) -> AddressConfigurationContext:
|
||||
"""
|
||||
Constructs a AddressConfigurationContext
|
||||
|
||||
:param sid: The SID of the Address Configuration resource. This value can be either the `sid` or the `address` of the configuration
|
||||
"""
|
||||
return AddressConfigurationContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> AddressConfigurationContext:
|
||||
"""
|
||||
Constructs a AddressConfigurationContext
|
||||
|
||||
:param sid: The SID of the Address Configuration resource. This value can be either the `sid` or the `address` of the configuration
|
||||
"""
|
||||
return AddressConfigurationContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.AddressConfigurationList>"
|
||||
+313
@@ -0,0 +1,313 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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, Union
|
||||
from twilio.base import values
|
||||
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.rest.conversations.v1.configuration.webhook import WebhookList
|
||||
|
||||
|
||||
class ConfigurationInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this configuration.
|
||||
:ivar default_chat_service_sid: The SID of the default [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) used when creating a conversation.
|
||||
:ivar default_messaging_service_sid: The SID of the default [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) used when creating a conversation.
|
||||
:ivar default_inactive_timer: Default ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute.
|
||||
:ivar default_closed_timer: Default ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes.
|
||||
:ivar url: An absolute API resource URL for this global configuration.
|
||||
:ivar links: Contains absolute API resource URLs to access the webhook and default service configurations.
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any]):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.default_chat_service_sid: Optional[str] = payload.get(
|
||||
"default_chat_service_sid"
|
||||
)
|
||||
self.default_messaging_service_sid: Optional[str] = payload.get(
|
||||
"default_messaging_service_sid"
|
||||
)
|
||||
self.default_inactive_timer: Optional[str] = payload.get(
|
||||
"default_inactive_timer"
|
||||
)
|
||||
self.default_closed_timer: Optional[str] = payload.get("default_closed_timer")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
|
||||
self._context: Optional[ConfigurationContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "ConfigurationContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: ConfigurationContext for this ConfigurationInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = ConfigurationContext(
|
||||
self._version,
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "ConfigurationInstance":
|
||||
"""
|
||||
Fetch the ConfigurationInstance
|
||||
|
||||
|
||||
:returns: The fetched ConfigurationInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "ConfigurationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ConfigurationInstance
|
||||
|
||||
|
||||
:returns: The fetched ConfigurationInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
default_chat_service_sid: Union[str, object] = values.unset,
|
||||
default_messaging_service_sid: Union[str, object] = values.unset,
|
||||
default_inactive_timer: Union[str, object] = values.unset,
|
||||
default_closed_timer: Union[str, object] = values.unset,
|
||||
) -> "ConfigurationInstance":
|
||||
"""
|
||||
Update the ConfigurationInstance
|
||||
|
||||
:param default_chat_service_sid: The SID of the default [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) to use when creating a conversation.
|
||||
:param default_messaging_service_sid: The SID of the default [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to use when creating a conversation.
|
||||
:param default_inactive_timer: Default ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute.
|
||||
:param default_closed_timer: Default ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes.
|
||||
|
||||
:returns: The updated ConfigurationInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
default_chat_service_sid=default_chat_service_sid,
|
||||
default_messaging_service_sid=default_messaging_service_sid,
|
||||
default_inactive_timer=default_inactive_timer,
|
||||
default_closed_timer=default_closed_timer,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
default_chat_service_sid: Union[str, object] = values.unset,
|
||||
default_messaging_service_sid: Union[str, object] = values.unset,
|
||||
default_inactive_timer: Union[str, object] = values.unset,
|
||||
default_closed_timer: Union[str, object] = values.unset,
|
||||
) -> "ConfigurationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the ConfigurationInstance
|
||||
|
||||
:param default_chat_service_sid: The SID of the default [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) to use when creating a conversation.
|
||||
:param default_messaging_service_sid: The SID of the default [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to use when creating a conversation.
|
||||
:param default_inactive_timer: Default ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute.
|
||||
:param default_closed_timer: Default ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes.
|
||||
|
||||
:returns: The updated ConfigurationInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
default_chat_service_sid=default_chat_service_sid,
|
||||
default_messaging_service_sid=default_messaging_service_sid,
|
||||
default_inactive_timer=default_inactive_timer,
|
||||
default_closed_timer=default_closed_timer,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
|
||||
return "<Twilio.Conversations.V1.ConfigurationInstance>"
|
||||
|
||||
|
||||
class ConfigurationContext(InstanceContext):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the ConfigurationContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/Configuration"
|
||||
|
||||
def fetch(self) -> ConfigurationInstance:
|
||||
"""
|
||||
Fetch the ConfigurationInstance
|
||||
|
||||
|
||||
:returns: The fetched ConfigurationInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ConfigurationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> ConfigurationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ConfigurationInstance
|
||||
|
||||
|
||||
:returns: The fetched ConfigurationInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ConfigurationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
default_chat_service_sid: Union[str, object] = values.unset,
|
||||
default_messaging_service_sid: Union[str, object] = values.unset,
|
||||
default_inactive_timer: Union[str, object] = values.unset,
|
||||
default_closed_timer: Union[str, object] = values.unset,
|
||||
) -> ConfigurationInstance:
|
||||
"""
|
||||
Update the ConfigurationInstance
|
||||
|
||||
:param default_chat_service_sid: The SID of the default [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) to use when creating a conversation.
|
||||
:param default_messaging_service_sid: The SID of the default [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to use when creating a conversation.
|
||||
:param default_inactive_timer: Default ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute.
|
||||
:param default_closed_timer: Default ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes.
|
||||
|
||||
:returns: The updated ConfigurationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DefaultChatServiceSid": default_chat_service_sid,
|
||||
"DefaultMessagingServiceSid": default_messaging_service_sid,
|
||||
"DefaultInactiveTimer": default_inactive_timer,
|
||||
"DefaultClosedTimer": default_closed_timer,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ConfigurationInstance(self._version, payload)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
default_chat_service_sid: Union[str, object] = values.unset,
|
||||
default_messaging_service_sid: Union[str, object] = values.unset,
|
||||
default_inactive_timer: Union[str, object] = values.unset,
|
||||
default_closed_timer: Union[str, object] = values.unset,
|
||||
) -> ConfigurationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the ConfigurationInstance
|
||||
|
||||
:param default_chat_service_sid: The SID of the default [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) to use when creating a conversation.
|
||||
:param default_messaging_service_sid: The SID of the default [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to use when creating a conversation.
|
||||
:param default_inactive_timer: Default ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute.
|
||||
:param default_closed_timer: Default ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes.
|
||||
|
||||
:returns: The updated ConfigurationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DefaultChatServiceSid": default_chat_service_sid,
|
||||
"DefaultMessagingServiceSid": default_messaging_service_sid,
|
||||
"DefaultInactiveTimer": default_inactive_timer,
|
||||
"DefaultClosedTimer": default_closed_timer,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ConfigurationInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
|
||||
return "<Twilio.Conversations.V1.ConfigurationContext>"
|
||||
|
||||
|
||||
class ConfigurationList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the ConfigurationList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._webhooks: Optional[WebhookList] = None
|
||||
|
||||
@property
|
||||
def webhooks(self) -> WebhookList:
|
||||
"""
|
||||
Access the webhooks
|
||||
"""
|
||||
if self._webhooks is None:
|
||||
self._webhooks = WebhookList(self._version)
|
||||
return self._webhooks
|
||||
|
||||
def get(self) -> ConfigurationContext:
|
||||
"""
|
||||
Constructs a ConfigurationContext
|
||||
|
||||
"""
|
||||
return ConfigurationContext(self._version)
|
||||
|
||||
def __call__(self) -> ConfigurationContext:
|
||||
"""
|
||||
Constructs a ConfigurationContext
|
||||
|
||||
"""
|
||||
return ConfigurationContext(self._version)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.ConfigurationList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+313
@@ -0,0 +1,313 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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, Union
|
||||
from twilio.base import serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class WebhookInstance(InstanceResource):
|
||||
class Method(object):
|
||||
GET = "GET"
|
||||
POST = "POST"
|
||||
|
||||
class Target(object):
|
||||
WEBHOOK = "webhook"
|
||||
FLEX = "flex"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this conversation.
|
||||
:ivar method:
|
||||
:ivar filters: The list of webhook event triggers that are enabled for this Service: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onConversationUpdated`, `onConversationRemoved`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`
|
||||
:ivar pre_webhook_url: The absolute url the pre-event webhook request should be sent to.
|
||||
:ivar post_webhook_url: The absolute url the post-event webhook request should be sent to.
|
||||
:ivar target:
|
||||
:ivar url: An absolute API resource API resource URL for this webhook.
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any]):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.method: Optional["WebhookInstance.Method"] = payload.get("method")
|
||||
self.filters: Optional[List[str]] = payload.get("filters")
|
||||
self.pre_webhook_url: Optional[str] = payload.get("pre_webhook_url")
|
||||
self.post_webhook_url: Optional[str] = payload.get("post_webhook_url")
|
||||
self.target: Optional["WebhookInstance.Target"] = payload.get("target")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._context: Optional[WebhookContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "WebhookContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: WebhookContext for this WebhookInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = WebhookContext(
|
||||
self._version,
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "WebhookInstance":
|
||||
"""
|
||||
Fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "WebhookInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
method: Union[str, object] = values.unset,
|
||||
filters: Union[List[str], object] = values.unset,
|
||||
pre_webhook_url: Union[str, object] = values.unset,
|
||||
post_webhook_url: Union[str, object] = values.unset,
|
||||
target: Union["WebhookInstance.Target", object] = values.unset,
|
||||
) -> "WebhookInstance":
|
||||
"""
|
||||
Update the WebhookInstance
|
||||
|
||||
:param method: The HTTP method to be used when sending a webhook request.
|
||||
:param filters: The list of webhook event triggers that are enabled for this Service: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onConversationUpdated`, `onConversationRemoved`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`
|
||||
:param pre_webhook_url: The absolute url the pre-event webhook request should be sent to.
|
||||
:param post_webhook_url: The absolute url the post-event webhook request should be sent to.
|
||||
:param target:
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
method=method,
|
||||
filters=filters,
|
||||
pre_webhook_url=pre_webhook_url,
|
||||
post_webhook_url=post_webhook_url,
|
||||
target=target,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
method: Union[str, object] = values.unset,
|
||||
filters: Union[List[str], object] = values.unset,
|
||||
pre_webhook_url: Union[str, object] = values.unset,
|
||||
post_webhook_url: Union[str, object] = values.unset,
|
||||
target: Union["WebhookInstance.Target", object] = values.unset,
|
||||
) -> "WebhookInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the WebhookInstance
|
||||
|
||||
:param method: The HTTP method to be used when sending a webhook request.
|
||||
:param filters: The list of webhook event triggers that are enabled for this Service: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onConversationUpdated`, `onConversationRemoved`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`
|
||||
:param pre_webhook_url: The absolute url the pre-event webhook request should be sent to.
|
||||
:param post_webhook_url: The absolute url the post-event webhook request should be sent to.
|
||||
:param target:
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
method=method,
|
||||
filters=filters,
|
||||
pre_webhook_url=pre_webhook_url,
|
||||
post_webhook_url=post_webhook_url,
|
||||
target=target,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
|
||||
return "<Twilio.Conversations.V1.WebhookInstance>"
|
||||
|
||||
|
||||
class WebhookContext(InstanceContext):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the WebhookContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/Configuration/Webhooks"
|
||||
|
||||
def fetch(self) -> WebhookInstance:
|
||||
"""
|
||||
Fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> WebhookInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
method: Union[str, object] = values.unset,
|
||||
filters: Union[List[str], object] = values.unset,
|
||||
pre_webhook_url: Union[str, object] = values.unset,
|
||||
post_webhook_url: Union[str, object] = values.unset,
|
||||
target: Union["WebhookInstance.Target", object] = values.unset,
|
||||
) -> WebhookInstance:
|
||||
"""
|
||||
Update the WebhookInstance
|
||||
|
||||
:param method: The HTTP method to be used when sending a webhook request.
|
||||
:param filters: The list of webhook event triggers that are enabled for this Service: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onConversationUpdated`, `onConversationRemoved`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`
|
||||
:param pre_webhook_url: The absolute url the pre-event webhook request should be sent to.
|
||||
:param post_webhook_url: The absolute url the post-event webhook request should be sent to.
|
||||
:param target:
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Method": method,
|
||||
"Filters": serialize.map(filters, lambda e: e),
|
||||
"PreWebhookUrl": pre_webhook_url,
|
||||
"PostWebhookUrl": post_webhook_url,
|
||||
"Target": target,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WebhookInstance(self._version, payload)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
method: Union[str, object] = values.unset,
|
||||
filters: Union[List[str], object] = values.unset,
|
||||
pre_webhook_url: Union[str, object] = values.unset,
|
||||
post_webhook_url: Union[str, object] = values.unset,
|
||||
target: Union["WebhookInstance.Target", object] = values.unset,
|
||||
) -> WebhookInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the WebhookInstance
|
||||
|
||||
:param method: The HTTP method to be used when sending a webhook request.
|
||||
:param filters: The list of webhook event triggers that are enabled for this Service: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onConversationUpdated`, `onConversationRemoved`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`
|
||||
:param pre_webhook_url: The absolute url the pre-event webhook request should be sent to.
|
||||
:param post_webhook_url: The absolute url the post-event webhook request should be sent to.
|
||||
:param target:
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Method": method,
|
||||
"Filters": serialize.map(filters, lambda e: e),
|
||||
"PreWebhookUrl": pre_webhook_url,
|
||||
"PostWebhookUrl": post_webhook_url,
|
||||
"Target": target,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WebhookInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
|
||||
return "<Twilio.Conversations.V1.WebhookContext>"
|
||||
|
||||
|
||||
class WebhookList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the WebhookList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
def get(self) -> WebhookContext:
|
||||
"""
|
||||
Constructs a WebhookContext
|
||||
|
||||
"""
|
||||
return WebhookContext(self._version)
|
||||
|
||||
def __call__(self) -> WebhookContext:
|
||||
"""
|
||||
Constructs a WebhookContext
|
||||
|
||||
"""
|
||||
return WebhookContext(self._version)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.WebhookList>"
|
||||
+970
@@ -0,0 +1,970 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
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.page import Page
|
||||
from twilio.rest.conversations.v1.conversation.message import MessageList
|
||||
from twilio.rest.conversations.v1.conversation.participant import ParticipantList
|
||||
from twilio.rest.conversations.v1.conversation.webhook import WebhookList
|
||||
|
||||
|
||||
class ConversationInstance(InstanceResource):
|
||||
class State(object):
|
||||
INACTIVE = "inactive"
|
||||
ACTIVE = "active"
|
||||
CLOSED = "closed"
|
||||
|
||||
class WebhookEnabledType(object):
|
||||
TRUE = "true"
|
||||
FALSE = "false"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this conversation.
|
||||
:ivar chat_service_sid: The unique ID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation belongs to.
|
||||
:ivar messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to.
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar friendly_name: The human-readable name of this conversation, limited to 256 characters. Optional.
|
||||
:ivar unique_name: An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL.
|
||||
:ivar attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \"{}\" will be returned.
|
||||
:ivar state:
|
||||
:ivar date_created: The date that this resource was created.
|
||||
:ivar date_updated: The date that this resource was last updated.
|
||||
:ivar timers: Timer date values representing state update for this conversation.
|
||||
:ivar url: An absolute API resource URL for this conversation.
|
||||
:ivar links: Contains absolute URLs to access the [participants](https://www.twilio.com/docs/conversations/api/conversation-participant-resource), [messages](https://www.twilio.com/docs/conversations/api/conversation-message-resource) and [webhooks](https://www.twilio.com/docs/conversations/api/conversation-scoped-webhook-resource) of this conversation.
|
||||
:ivar bindings:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.chat_service_sid: Optional[str] = payload.get("chat_service_sid")
|
||||
self.messaging_service_sid: Optional[str] = payload.get("messaging_service_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.unique_name: Optional[str] = payload.get("unique_name")
|
||||
self.attributes: Optional[str] = payload.get("attributes")
|
||||
self.state: Optional["ConversationInstance.State"] = payload.get("state")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.timers: Optional[Dict[str, object]] = payload.get("timers")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
self.bindings: Optional[Dict[str, object]] = payload.get("bindings")
|
||||
|
||||
self._solution = {
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[ConversationContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "ConversationContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: ConversationContext for this ConversationInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = ConversationContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ConversationInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Deletes the ConversationInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
)
|
||||
|
||||
async def delete_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ConversationInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ConversationInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
)
|
||||
|
||||
def fetch(self) -> "ConversationInstance":
|
||||
"""
|
||||
Fetch the ConversationInstance
|
||||
|
||||
|
||||
:returns: The fetched ConversationInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "ConversationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ConversationInstance
|
||||
|
||||
|
||||
:returns: The fetched ConversationInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ConversationInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
messaging_service_sid: Union[str, object] = values.unset,
|
||||
state: Union["ConversationInstance.State", object] = values.unset,
|
||||
timers_inactive: Union[str, object] = values.unset,
|
||||
timers_closed: Union[str, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
bindings_email_address: Union[str, object] = values.unset,
|
||||
bindings_email_name: Union[str, object] = values.unset,
|
||||
) -> "ConversationInstance":
|
||||
"""
|
||||
Update the ConversationInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param friendly_name: The human-readable name of this conversation, limited to 256 characters. Optional.
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated.
|
||||
:param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to.
|
||||
:param state:
|
||||
:param timers_inactive: ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute.
|
||||
:param timers_closed: ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes.
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL.
|
||||
:param bindings_email_address: The default email address that will be used when sending outbound emails in this conversation.
|
||||
:param bindings_email_name: The default name that will be used when sending outbound emails in this conversation.
|
||||
|
||||
:returns: The updated ConversationInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
friendly_name=friendly_name,
|
||||
date_created=date_created,
|
||||
date_updated=date_updated,
|
||||
attributes=attributes,
|
||||
messaging_service_sid=messaging_service_sid,
|
||||
state=state,
|
||||
timers_inactive=timers_inactive,
|
||||
timers_closed=timers_closed,
|
||||
unique_name=unique_name,
|
||||
bindings_email_address=bindings_email_address,
|
||||
bindings_email_name=bindings_email_name,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ConversationInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
messaging_service_sid: Union[str, object] = values.unset,
|
||||
state: Union["ConversationInstance.State", object] = values.unset,
|
||||
timers_inactive: Union[str, object] = values.unset,
|
||||
timers_closed: Union[str, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
bindings_email_address: Union[str, object] = values.unset,
|
||||
bindings_email_name: Union[str, object] = values.unset,
|
||||
) -> "ConversationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the ConversationInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param friendly_name: The human-readable name of this conversation, limited to 256 characters. Optional.
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated.
|
||||
:param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to.
|
||||
:param state:
|
||||
:param timers_inactive: ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute.
|
||||
:param timers_closed: ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes.
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL.
|
||||
:param bindings_email_address: The default email address that will be used when sending outbound emails in this conversation.
|
||||
:param bindings_email_name: The default name that will be used when sending outbound emails in this conversation.
|
||||
|
||||
:returns: The updated ConversationInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
friendly_name=friendly_name,
|
||||
date_created=date_created,
|
||||
date_updated=date_updated,
|
||||
attributes=attributes,
|
||||
messaging_service_sid=messaging_service_sid,
|
||||
state=state,
|
||||
timers_inactive=timers_inactive,
|
||||
timers_closed=timers_closed,
|
||||
unique_name=unique_name,
|
||||
bindings_email_address=bindings_email_address,
|
||||
bindings_email_name=bindings_email_name,
|
||||
)
|
||||
|
||||
@property
|
||||
def messages(self) -> MessageList:
|
||||
"""
|
||||
Access the messages
|
||||
"""
|
||||
return self._proxy.messages
|
||||
|
||||
@property
|
||||
def participants(self) -> ParticipantList:
|
||||
"""
|
||||
Access the participants
|
||||
"""
|
||||
return self._proxy.participants
|
||||
|
||||
@property
|
||||
def webhooks(self) -> WebhookList:
|
||||
"""
|
||||
Access the webhooks
|
||||
"""
|
||||
return self._proxy.webhooks
|
||||
|
||||
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 "<Twilio.Conversations.V1.ConversationInstance {}>".format(context)
|
||||
|
||||
|
||||
class ConversationContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the ConversationContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: A 34 character string that uniquely identifies this resource. Can also be the `unique_name` of the Conversation.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Conversations/{sid}".format(**self._solution)
|
||||
|
||||
self._messages: Optional[MessageList] = None
|
||||
self._participants: Optional[ParticipantList] = None
|
||||
self._webhooks: Optional[WebhookList] = None
|
||||
|
||||
def delete(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ConversationInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Deletes the ConversationInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
return self._version.delete(method="DELETE", uri=self._uri, headers=headers)
|
||||
|
||||
async def delete_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ConversationInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ConversationInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
return await self._version.delete_async(
|
||||
method="DELETE", uri=self._uri, headers=headers
|
||||
)
|
||||
|
||||
def fetch(self) -> ConversationInstance:
|
||||
"""
|
||||
Fetch the ConversationInstance
|
||||
|
||||
|
||||
:returns: The fetched ConversationInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ConversationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> ConversationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ConversationInstance
|
||||
|
||||
|
||||
:returns: The fetched ConversationInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ConversationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ConversationInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
messaging_service_sid: Union[str, object] = values.unset,
|
||||
state: Union["ConversationInstance.State", object] = values.unset,
|
||||
timers_inactive: Union[str, object] = values.unset,
|
||||
timers_closed: Union[str, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
bindings_email_address: Union[str, object] = values.unset,
|
||||
bindings_email_name: Union[str, object] = values.unset,
|
||||
) -> ConversationInstance:
|
||||
"""
|
||||
Update the ConversationInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param friendly_name: The human-readable name of this conversation, limited to 256 characters. Optional.
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated.
|
||||
:param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to.
|
||||
:param state:
|
||||
:param timers_inactive: ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute.
|
||||
:param timers_closed: ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes.
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL.
|
||||
:param bindings_email_address: The default email address that will be used when sending outbound emails in this conversation.
|
||||
:param bindings_email_name: The default name that will be used when sending outbound emails in this conversation.
|
||||
|
||||
:returns: The updated ConversationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateUpdated": serialize.iso8601_datetime(date_updated),
|
||||
"Attributes": attributes,
|
||||
"MessagingServiceSid": messaging_service_sid,
|
||||
"State": state,
|
||||
"Timers.Inactive": timers_inactive,
|
||||
"Timers.Closed": timers_closed,
|
||||
"UniqueName": unique_name,
|
||||
"Bindings.Email.Address": bindings_email_address,
|
||||
"Bindings.Email.Name": bindings_email_name,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return ConversationInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ConversationInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
messaging_service_sid: Union[str, object] = values.unset,
|
||||
state: Union["ConversationInstance.State", object] = values.unset,
|
||||
timers_inactive: Union[str, object] = values.unset,
|
||||
timers_closed: Union[str, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
bindings_email_address: Union[str, object] = values.unset,
|
||||
bindings_email_name: Union[str, object] = values.unset,
|
||||
) -> ConversationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the ConversationInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param friendly_name: The human-readable name of this conversation, limited to 256 characters. Optional.
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated.
|
||||
:param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to.
|
||||
:param state:
|
||||
:param timers_inactive: ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute.
|
||||
:param timers_closed: ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes.
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL.
|
||||
:param bindings_email_address: The default email address that will be used when sending outbound emails in this conversation.
|
||||
:param bindings_email_name: The default name that will be used when sending outbound emails in this conversation.
|
||||
|
||||
:returns: The updated ConversationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateUpdated": serialize.iso8601_datetime(date_updated),
|
||||
"Attributes": attributes,
|
||||
"MessagingServiceSid": messaging_service_sid,
|
||||
"State": state,
|
||||
"Timers.Inactive": timers_inactive,
|
||||
"Timers.Closed": timers_closed,
|
||||
"UniqueName": unique_name,
|
||||
"Bindings.Email.Address": bindings_email_address,
|
||||
"Bindings.Email.Name": bindings_email_name,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return ConversationInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
@property
|
||||
def messages(self) -> MessageList:
|
||||
"""
|
||||
Access the messages
|
||||
"""
|
||||
if self._messages is None:
|
||||
self._messages = MessageList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._messages
|
||||
|
||||
@property
|
||||
def participants(self) -> ParticipantList:
|
||||
"""
|
||||
Access the participants
|
||||
"""
|
||||
if self._participants is None:
|
||||
self._participants = ParticipantList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._participants
|
||||
|
||||
@property
|
||||
def webhooks(self) -> WebhookList:
|
||||
"""
|
||||
Access the webhooks
|
||||
"""
|
||||
if self._webhooks is None:
|
||||
self._webhooks = WebhookList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._webhooks
|
||||
|
||||
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 "<Twilio.Conversations.V1.ConversationContext {}>".format(context)
|
||||
|
||||
|
||||
class ConversationPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> ConversationInstance:
|
||||
"""
|
||||
Build an instance of ConversationInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return ConversationInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.ConversationPage>"
|
||||
|
||||
|
||||
class ConversationList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the ConversationList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/Conversations"
|
||||
|
||||
def create(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ConversationInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
messaging_service_sid: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
state: Union["ConversationInstance.State", object] = values.unset,
|
||||
timers_inactive: Union[str, object] = values.unset,
|
||||
timers_closed: Union[str, object] = values.unset,
|
||||
bindings_email_address: Union[str, object] = values.unset,
|
||||
bindings_email_name: Union[str, object] = values.unset,
|
||||
) -> ConversationInstance:
|
||||
"""
|
||||
Create the ConversationInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param friendly_name: The human-readable name of this conversation, limited to 256 characters. Optional.
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL.
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated.
|
||||
:param messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to.
|
||||
:param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param state:
|
||||
:param timers_inactive: ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute.
|
||||
:param timers_closed: ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes.
|
||||
:param bindings_email_address: The default email address that will be used when sending outbound emails in this conversation.
|
||||
:param bindings_email_name: The default name that will be used when sending outbound emails in this conversation.
|
||||
|
||||
:returns: The created ConversationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"UniqueName": unique_name,
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateUpdated": serialize.iso8601_datetime(date_updated),
|
||||
"MessagingServiceSid": messaging_service_sid,
|
||||
"Attributes": attributes,
|
||||
"State": state,
|
||||
"Timers.Inactive": timers_inactive,
|
||||
"Timers.Closed": timers_closed,
|
||||
"Bindings.Email.Address": bindings_email_address,
|
||||
"Bindings.Email.Name": bindings_email_name,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
payload = self._version.create(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return ConversationInstance(self._version, payload)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ConversationInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
messaging_service_sid: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
state: Union["ConversationInstance.State", object] = values.unset,
|
||||
timers_inactive: Union[str, object] = values.unset,
|
||||
timers_closed: Union[str, object] = values.unset,
|
||||
bindings_email_address: Union[str, object] = values.unset,
|
||||
bindings_email_name: Union[str, object] = values.unset,
|
||||
) -> ConversationInstance:
|
||||
"""
|
||||
Asynchronously create the ConversationInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param friendly_name: The human-readable name of this conversation, limited to 256 characters. Optional.
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL.
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated.
|
||||
:param messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to.
|
||||
:param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param state:
|
||||
:param timers_inactive: ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute.
|
||||
:param timers_closed: ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes.
|
||||
:param bindings_email_address: The default email address that will be used when sending outbound emails in this conversation.
|
||||
:param bindings_email_name: The default name that will be used when sending outbound emails in this conversation.
|
||||
|
||||
:returns: The created ConversationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"UniqueName": unique_name,
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateUpdated": serialize.iso8601_datetime(date_updated),
|
||||
"MessagingServiceSid": messaging_service_sid,
|
||||
"Attributes": attributes,
|
||||
"State": state,
|
||||
"Timers.Inactive": timers_inactive,
|
||||
"Timers.Closed": timers_closed,
|
||||
"Bindings.Email.Address": bindings_email_address,
|
||||
"Bindings.Email.Name": bindings_email_name,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
payload = await self._version.create_async(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return ConversationInstance(self._version, payload)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
start_date: Union[str, object] = values.unset,
|
||||
end_date: Union[str, object] = values.unset,
|
||||
state: Union["ConversationInstance.State", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[ConversationInstance]:
|
||||
"""
|
||||
Streams ConversationInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str start_date: Start date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the start time of the date is used (YYYY-MM-DDT00:00:00Z). Can be combined with other filters.
|
||||
:param str end_date: End date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the end time of the date is used (YYYY-MM-DDT23:59:59Z). Can be combined with other filters.
|
||||
:param "ConversationInstance.State" state: State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed`
|
||||
: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(
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
state=state,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
start_date: Union[str, object] = values.unset,
|
||||
end_date: Union[str, object] = values.unset,
|
||||
state: Union["ConversationInstance.State", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[ConversationInstance]:
|
||||
"""
|
||||
Asynchronously streams ConversationInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str start_date: Start date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the start time of the date is used (YYYY-MM-DDT00:00:00Z). Can be combined with other filters.
|
||||
:param str end_date: End date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the end time of the date is used (YYYY-MM-DDT23:59:59Z). Can be combined with other filters.
|
||||
:param "ConversationInstance.State" state: State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed`
|
||||
: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(
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
state=state,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
start_date: Union[str, object] = values.unset,
|
||||
end_date: Union[str, object] = values.unset,
|
||||
state: Union["ConversationInstance.State", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ConversationInstance]:
|
||||
"""
|
||||
Lists ConversationInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str start_date: Start date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the start time of the date is used (YYYY-MM-DDT00:00:00Z). Can be combined with other filters.
|
||||
:param str end_date: End date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the end time of the date is used (YYYY-MM-DDT23:59:59Z). Can be combined with other filters.
|
||||
:param "ConversationInstance.State" state: State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed`
|
||||
: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(
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
state=state,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
start_date: Union[str, object] = values.unset,
|
||||
end_date: Union[str, object] = values.unset,
|
||||
state: Union["ConversationInstance.State", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ConversationInstance]:
|
||||
"""
|
||||
Asynchronously lists ConversationInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str start_date: Start date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the start time of the date is used (YYYY-MM-DDT00:00:00Z). Can be combined with other filters.
|
||||
:param str end_date: End date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the end time of the date is used (YYYY-MM-DDT23:59:59Z). Can be combined with other filters.
|
||||
:param "ConversationInstance.State" state: State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed`
|
||||
: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(
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
state=state,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
start_date: Union[str, object] = values.unset,
|
||||
end_date: Union[str, object] = values.unset,
|
||||
state: Union["ConversationInstance.State", object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ConversationPage:
|
||||
"""
|
||||
Retrieve a single page of ConversationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param start_date: Start date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the start time of the date is used (YYYY-MM-DDT00:00:00Z). Can be combined with other filters.
|
||||
:param end_date: End date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the end time of the date is used (YYYY-MM-DDT23:59:59Z). Can be combined with other filters.
|
||||
:param state: State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed`
|
||||
: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: Page of ConversationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"StartDate": start_date,
|
||||
"EndDate": end_date,
|
||||
"State": state,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return ConversationPage(self._version, response)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
start_date: Union[str, object] = values.unset,
|
||||
end_date: Union[str, object] = values.unset,
|
||||
state: Union["ConversationInstance.State", object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ConversationPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of ConversationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param start_date: Start date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the start time of the date is used (YYYY-MM-DDT00:00:00Z). Can be combined with other filters.
|
||||
:param end_date: End date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the end time of the date is used (YYYY-MM-DDT23:59:59Z). Can be combined with other filters.
|
||||
:param state: State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed`
|
||||
: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: Page of ConversationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"StartDate": start_date,
|
||||
"EndDate": end_date,
|
||||
"State": state,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return ConversationPage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> ConversationPage:
|
||||
"""
|
||||
Retrieve a specific page of ConversationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ConversationInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return ConversationPage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> ConversationPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of ConversationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ConversationInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return ConversationPage(self._version, response)
|
||||
|
||||
def get(self, sid: str) -> ConversationContext:
|
||||
"""
|
||||
Constructs a ConversationContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource. Can also be the `unique_name` of the Conversation.
|
||||
"""
|
||||
return ConversationContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> ConversationContext:
|
||||
"""
|
||||
Constructs a ConversationContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource. Can also be the `unique_name` of the Conversation.
|
||||
"""
|
||||
return ConversationContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.ConversationList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+857
@@ -0,0 +1,857 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
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.page import Page
|
||||
from twilio.rest.conversations.v1.conversation.message.delivery_receipt import (
|
||||
DeliveryReceiptList,
|
||||
)
|
||||
|
||||
|
||||
class MessageInstance(InstanceResource):
|
||||
class OrderType(object):
|
||||
ASC = "asc"
|
||||
DESC = "desc"
|
||||
|
||||
class WebhookEnabledType(object):
|
||||
TRUE = "true"
|
||||
FALSE = "false"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this message.
|
||||
:ivar conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this message.
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar index: The index of the message within the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource). Indices may skip numbers, but will always be in order of when the message was received.
|
||||
:ivar author: The channel specific identifier of the message's author. Defaults to `system`.
|
||||
:ivar body: The content of the message, can be up to 1,600 characters long.
|
||||
:ivar media: An array of objects that describe the Message's media, if the message contains media. Each object contains these fields: `content_type` with the MIME type of the media, `filename` with the name of the media, `sid` with the SID of the Media resource, and `size` with the media object's file size in bytes. If the Message has no media, this value is `null`.
|
||||
:ivar attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \"{}\" will be returned.
|
||||
:ivar participant_sid: The unique ID of messages's author participant. Null in case of `system` sent message.
|
||||
:ivar date_created: The date that this resource was created.
|
||||
:ivar date_updated: The date that this resource was last updated. `null` if the message has not been edited.
|
||||
:ivar url: An absolute API resource API URL for this message.
|
||||
:ivar delivery: An object that contains the summary of delivery statuses for the message to non-chat participants.
|
||||
:ivar links: Contains an absolute API resource URL to access the delivery & read receipts of this message.
|
||||
:ivar content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content-api) template.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
conversation_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.conversation_sid: Optional[str] = payload.get("conversation_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
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[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(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.delivery: Optional[Dict[str, object]] = payload.get("delivery")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
self.content_sid: Optional[str] = payload.get("content_sid")
|
||||
|
||||
self._solution = {
|
||||
"conversation_sid": conversation_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[MessageContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "MessageContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: MessageContext for this MessageInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = MessageContext(
|
||||
self._version,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"MessageInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Deletes the MessageInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
)
|
||||
|
||||
async def delete_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"MessageInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the MessageInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
)
|
||||
|
||||
def fetch(self) -> "MessageInstance":
|
||||
"""
|
||||
Fetch the MessageInstance
|
||||
|
||||
|
||||
:returns: The fetched MessageInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "MessageInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the MessageInstance
|
||||
|
||||
|
||||
:returns: The fetched MessageInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"MessageInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
author: Union[str, object] = values.unset,
|
||||
body: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
subject: Union[str, object] = values.unset,
|
||||
) -> "MessageInstance":
|
||||
"""
|
||||
Update the MessageInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param author: The channel specific identifier of the message's author. Defaults to `system`.
|
||||
:param body: The content of the message, can be up to 1,600 characters long.
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated. `null` if the message has not been edited.
|
||||
:param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param subject: The subject of the message, can be up to 256 characters long.
|
||||
|
||||
:returns: The updated MessageInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
author=author,
|
||||
body=body,
|
||||
date_created=date_created,
|
||||
date_updated=date_updated,
|
||||
attributes=attributes,
|
||||
subject=subject,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"MessageInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
author: Union[str, object] = values.unset,
|
||||
body: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
subject: Union[str, object] = values.unset,
|
||||
) -> "MessageInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the MessageInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param author: The channel specific identifier of the message's author. Defaults to `system`.
|
||||
:param body: The content of the message, can be up to 1,600 characters long.
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated. `null` if the message has not been edited.
|
||||
:param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param subject: The subject of the message, can be up to 256 characters long.
|
||||
|
||||
:returns: The updated MessageInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
author=author,
|
||||
body=body,
|
||||
date_created=date_created,
|
||||
date_updated=date_updated,
|
||||
attributes=attributes,
|
||||
subject=subject,
|
||||
)
|
||||
|
||||
@property
|
||||
def delivery_receipts(self) -> DeliveryReceiptList:
|
||||
"""
|
||||
Access the delivery_receipts
|
||||
"""
|
||||
return self._proxy.delivery_receipts
|
||||
|
||||
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 "<Twilio.Conversations.V1.MessageInstance {}>".format(context)
|
||||
|
||||
|
||||
class MessageContext(InstanceContext):
|
||||
def __init__(self, version: Version, conversation_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the MessageContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this message.
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"conversation_sid": conversation_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Conversations/{conversation_sid}/Messages/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
self._delivery_receipts: Optional[DeliveryReceiptList] = None
|
||||
|
||||
def delete(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"MessageInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Deletes the MessageInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
return self._version.delete(method="DELETE", uri=self._uri, headers=headers)
|
||||
|
||||
async def delete_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"MessageInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the MessageInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
return await self._version.delete_async(
|
||||
method="DELETE", uri=self._uri, headers=headers
|
||||
)
|
||||
|
||||
def fetch(self) -> MessageInstance:
|
||||
"""
|
||||
Fetch the MessageInstance
|
||||
|
||||
|
||||
:returns: The fetched MessageInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return MessageInstance(
|
||||
self._version,
|
||||
payload,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> MessageInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the MessageInstance
|
||||
|
||||
|
||||
:returns: The fetched MessageInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return MessageInstance(
|
||||
self._version,
|
||||
payload,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"MessageInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
author: Union[str, object] = values.unset,
|
||||
body: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
subject: Union[str, object] = values.unset,
|
||||
) -> MessageInstance:
|
||||
"""
|
||||
Update the MessageInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param author: The channel specific identifier of the message's author. Defaults to `system`.
|
||||
:param body: The content of the message, can be up to 1,600 characters long.
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated. `null` if the message has not been edited.
|
||||
:param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param subject: The subject of the message, can be up to 256 characters long.
|
||||
|
||||
:returns: The updated MessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Author": author,
|
||||
"Body": body,
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateUpdated": serialize.iso8601_datetime(date_updated),
|
||||
"Attributes": attributes,
|
||||
"Subject": subject,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return MessageInstance(
|
||||
self._version,
|
||||
payload,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"MessageInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
author: Union[str, object] = values.unset,
|
||||
body: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
subject: Union[str, object] = values.unset,
|
||||
) -> MessageInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the MessageInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param author: The channel specific identifier of the message's author. Defaults to `system`.
|
||||
:param body: The content of the message, can be up to 1,600 characters long.
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated. `null` if the message has not been edited.
|
||||
:param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param subject: The subject of the message, can be up to 256 characters long.
|
||||
|
||||
:returns: The updated MessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Author": author,
|
||||
"Body": body,
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateUpdated": serialize.iso8601_datetime(date_updated),
|
||||
"Attributes": attributes,
|
||||
"Subject": subject,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return MessageInstance(
|
||||
self._version,
|
||||
payload,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
@property
|
||||
def delivery_receipts(self) -> DeliveryReceiptList:
|
||||
"""
|
||||
Access the delivery_receipts
|
||||
"""
|
||||
if self._delivery_receipts is None:
|
||||
self._delivery_receipts = DeliveryReceiptList(
|
||||
self._version,
|
||||
self._solution["conversation_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._delivery_receipts
|
||||
|
||||
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 "<Twilio.Conversations.V1.MessageContext {}>".format(context)
|
||||
|
||||
|
||||
class MessagePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> MessageInstance:
|
||||
"""
|
||||
Build an instance of MessageInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return MessageInstance(
|
||||
self._version, payload, conversation_sid=self._solution["conversation_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.MessagePage>"
|
||||
|
||||
|
||||
class MessageList(ListResource):
|
||||
def __init__(self, version: Version, conversation_sid: str):
|
||||
"""
|
||||
Initialize the MessageList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for messages.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"conversation_sid": conversation_sid,
|
||||
}
|
||||
self._uri = "/Conversations/{conversation_sid}/Messages".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"MessageInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
author: Union[str, object] = values.unset,
|
||||
body: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
media_sid: Union[str, object] = values.unset,
|
||||
content_sid: Union[str, object] = values.unset,
|
||||
content_variables: Union[str, object] = values.unset,
|
||||
subject: Union[str, object] = values.unset,
|
||||
) -> MessageInstance:
|
||||
"""
|
||||
Create the MessageInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param author: The channel specific identifier of the message's author. Defaults to `system`.
|
||||
:param body: The content of the message, can be up to 1,600 characters long.
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated. `null` if the message has not been edited.
|
||||
:param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param media_sid: The Media SID to be attached to the new Message.
|
||||
:param content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content-api) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored.
|
||||
:param content_variables: A structurally valid JSON string that contains values to resolve Rich Content template variables.
|
||||
:param subject: The subject of the message, can be up to 256 characters long.
|
||||
|
||||
:returns: The created MessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Author": author,
|
||||
"Body": body,
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateUpdated": serialize.iso8601_datetime(date_updated),
|
||||
"Attributes": attributes,
|
||||
"MediaSid": media_sid,
|
||||
"ContentSid": content_sid,
|
||||
"ContentVariables": content_variables,
|
||||
"Subject": subject,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
payload = self._version.create(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return MessageInstance(
|
||||
self._version, payload, conversation_sid=self._solution["conversation_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"MessageInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
author: Union[str, object] = values.unset,
|
||||
body: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
media_sid: Union[str, object] = values.unset,
|
||||
content_sid: Union[str, object] = values.unset,
|
||||
content_variables: Union[str, object] = values.unset,
|
||||
subject: Union[str, object] = values.unset,
|
||||
) -> MessageInstance:
|
||||
"""
|
||||
Asynchronously create the MessageInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param author: The channel specific identifier of the message's author. Defaults to `system`.
|
||||
:param body: The content of the message, can be up to 1,600 characters long.
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated. `null` if the message has not been edited.
|
||||
:param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param media_sid: The Media SID to be attached to the new Message.
|
||||
:param content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content-api) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored.
|
||||
:param content_variables: A structurally valid JSON string that contains values to resolve Rich Content template variables.
|
||||
:param subject: The subject of the message, can be up to 256 characters long.
|
||||
|
||||
:returns: The created MessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Author": author,
|
||||
"Body": body,
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateUpdated": serialize.iso8601_datetime(date_updated),
|
||||
"Attributes": attributes,
|
||||
"MediaSid": media_sid,
|
||||
"ContentSid": content_sid,
|
||||
"ContentVariables": content_variables,
|
||||
"Subject": subject,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
payload = await self._version.create_async(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return MessageInstance(
|
||||
self._version, payload, conversation_sid=self._solution["conversation_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
order: Union["MessageInstance.OrderType", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[MessageInstance]:
|
||||
"""
|
||||
Streams MessageInstance 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 "MessageInstance.OrderType" order: The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending), with `asc` as the default.
|
||||
: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(order=order, page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
order: Union["MessageInstance.OrderType", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[MessageInstance]:
|
||||
"""
|
||||
Asynchronously streams MessageInstance 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 "MessageInstance.OrderType" order: The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending), with `asc` as the default.
|
||||
: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(order=order, page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
order: Union["MessageInstance.OrderType", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MessageInstance]:
|
||||
"""
|
||||
Lists MessageInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param "MessageInstance.OrderType" order: The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending), with `asc` as the default.
|
||||
: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(
|
||||
order=order,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
order: Union["MessageInstance.OrderType", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MessageInstance]:
|
||||
"""
|
||||
Asynchronously lists MessageInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param "MessageInstance.OrderType" order: The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending), with `asc` as the default.
|
||||
: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(
|
||||
order=order,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
order: Union["MessageInstance.OrderType", object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MessagePage:
|
||||
"""
|
||||
Retrieve a single page of MessageInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param order: The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending), with `asc` as the default.
|
||||
: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: Page of MessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Order": order,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return MessagePage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
order: Union["MessageInstance.OrderType", object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MessagePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of MessageInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param order: The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending), with `asc` as the default.
|
||||
: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: Page of MessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Order": order,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return MessagePage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> MessagePage:
|
||||
"""
|
||||
Retrieve a specific page of MessageInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MessageInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return MessagePage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> MessagePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of MessageInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MessageInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return MessagePage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> MessageContext:
|
||||
"""
|
||||
Constructs a MessageContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return MessageContext(
|
||||
self._version, conversation_sid=self._solution["conversation_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> MessageContext:
|
||||
"""
|
||||
Constructs a MessageContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return MessageContext(
|
||||
self._version, conversation_sid=self._solution["conversation_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.MessageList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+465
@@ -0,0 +1,465 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
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.page import Page
|
||||
|
||||
|
||||
class DeliveryReceiptInstance(InstanceResource):
|
||||
class DeliveryStatus(object):
|
||||
READ = "read"
|
||||
FAILED = "failed"
|
||||
DELIVERED = "delivered"
|
||||
UNDELIVERED = "undelivered"
|
||||
SENT = "sent"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this participant.
|
||||
:ivar conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this message.
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar message_sid: The SID of the message within a [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) the delivery receipt belongs to
|
||||
:ivar channel_message_sid: A messaging channel-specific identifier for the message delivered to participant e.g. `SMxx` for SMS, `WAxx` for Whatsapp etc.
|
||||
:ivar participant_sid: The unique ID of the participant the delivery receipt belongs to.
|
||||
:ivar status:
|
||||
:ivar error_code: The message [delivery error code](https://www.twilio.com/docs/sms/api/message-resource#delivery-related-errors) for a `failed` status,
|
||||
:ivar date_created: The date that this resource was created.
|
||||
:ivar date_updated: The date that this resource was last updated. `null` if the delivery receipt has not been updated.
|
||||
:ivar url: An absolute API resource URL for this delivery receipt.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
conversation_sid: str,
|
||||
message_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.conversation_sid: Optional[str] = payload.get("conversation_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.message_sid: Optional[str] = payload.get("message_sid")
|
||||
self.channel_message_sid: Optional[str] = payload.get("channel_message_sid")
|
||||
self.participant_sid: Optional[str] = payload.get("participant_sid")
|
||||
self.status: Optional["DeliveryReceiptInstance.DeliveryStatus"] = payload.get(
|
||||
"status"
|
||||
)
|
||||
self.error_code: Optional[int] = deserialize.integer(payload.get("error_code"))
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"conversation_sid": conversation_sid,
|
||||
"message_sid": message_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[DeliveryReceiptContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "DeliveryReceiptContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: DeliveryReceiptContext for this DeliveryReceiptInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = DeliveryReceiptContext(
|
||||
self._version,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
message_sid=self._solution["message_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "DeliveryReceiptInstance":
|
||||
"""
|
||||
Fetch the DeliveryReceiptInstance
|
||||
|
||||
|
||||
:returns: The fetched DeliveryReceiptInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "DeliveryReceiptInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the DeliveryReceiptInstance
|
||||
|
||||
|
||||
:returns: The fetched DeliveryReceiptInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
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 "<Twilio.Conversations.V1.DeliveryReceiptInstance {}>".format(context)
|
||||
|
||||
|
||||
class DeliveryReceiptContext(InstanceContext):
|
||||
def __init__(
|
||||
self, version: Version, conversation_sid: str, message_sid: str, sid: str
|
||||
):
|
||||
"""
|
||||
Initialize the DeliveryReceiptContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this message.
|
||||
:param message_sid: The SID of the message within a [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) the delivery receipt belongs to.
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"conversation_sid": conversation_sid,
|
||||
"message_sid": message_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Conversations/{conversation_sid}/Messages/{message_sid}/Receipts/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(self) -> DeliveryReceiptInstance:
|
||||
"""
|
||||
Fetch the DeliveryReceiptInstance
|
||||
|
||||
|
||||
:returns: The fetched DeliveryReceiptInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return DeliveryReceiptInstance(
|
||||
self._version,
|
||||
payload,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
message_sid=self._solution["message_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> DeliveryReceiptInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the DeliveryReceiptInstance
|
||||
|
||||
|
||||
:returns: The fetched DeliveryReceiptInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return DeliveryReceiptInstance(
|
||||
self._version,
|
||||
payload,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
message_sid=self._solution["message_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.DeliveryReceiptContext {}>".format(context)
|
||||
|
||||
|
||||
class DeliveryReceiptPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> DeliveryReceiptInstance:
|
||||
"""
|
||||
Build an instance of DeliveryReceiptInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return DeliveryReceiptInstance(
|
||||
self._version,
|
||||
payload,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
message_sid=self._solution["message_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.DeliveryReceiptPage>"
|
||||
|
||||
|
||||
class DeliveryReceiptList(ListResource):
|
||||
def __init__(self, version: Version, conversation_sid: str, message_sid: str):
|
||||
"""
|
||||
Initialize the DeliveryReceiptList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this message.
|
||||
:param message_sid: The SID of the message within a [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) the delivery receipt belongs to.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"conversation_sid": conversation_sid,
|
||||
"message_sid": message_sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Conversations/{conversation_sid}/Messages/{message_sid}/Receipts".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[DeliveryReceiptInstance]:
|
||||
"""
|
||||
Streams DeliveryReceiptInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[DeliveryReceiptInstance]:
|
||||
"""
|
||||
Asynchronously streams DeliveryReceiptInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[DeliveryReceiptInstance]:
|
||||
"""
|
||||
Lists DeliveryReceiptInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[DeliveryReceiptInstance]:
|
||||
"""
|
||||
Asynchronously lists DeliveryReceiptInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> DeliveryReceiptPage:
|
||||
"""
|
||||
Retrieve a single page of DeliveryReceiptInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of DeliveryReceiptInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return DeliveryReceiptPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> DeliveryReceiptPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of DeliveryReceiptInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of DeliveryReceiptInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return DeliveryReceiptPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> DeliveryReceiptPage:
|
||||
"""
|
||||
Retrieve a specific page of DeliveryReceiptInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of DeliveryReceiptInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return DeliveryReceiptPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> DeliveryReceiptPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of DeliveryReceiptInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of DeliveryReceiptInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return DeliveryReceiptPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> DeliveryReceiptContext:
|
||||
"""
|
||||
Constructs a DeliveryReceiptContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return DeliveryReceiptContext(
|
||||
self._version,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
message_sid=self._solution["message_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> DeliveryReceiptContext:
|
||||
"""
|
||||
Constructs a DeliveryReceiptContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return DeliveryReceiptContext(
|
||||
self._version,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
message_sid=self._solution["message_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.DeliveryReceiptList>"
|
||||
+840
@@ -0,0 +1,840 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
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.page import Page
|
||||
|
||||
|
||||
class ParticipantInstance(InstanceResource):
|
||||
class WebhookEnabledType(object):
|
||||
TRUE = "true"
|
||||
FALSE = "false"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this participant.
|
||||
:ivar conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this participant.
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:ivar attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \"{}\" will be returned.
|
||||
:ivar messaging_binding: Information about how this participant exchanges messages with the conversation. A JSON parameter consisting of type and address fields of the participant.
|
||||
:ivar role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant.
|
||||
:ivar date_created: The date that this resource was created.
|
||||
:ivar date_updated: The date that this resource was last updated.
|
||||
:ivar url: An absolute API resource URL for this participant.
|
||||
:ivar last_read_message_index: Index of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.
|
||||
:ivar last_read_timestamp: Timestamp of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
conversation_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.conversation_sid: Optional[str] = payload.get("conversation_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.identity: Optional[str] = payload.get("identity")
|
||||
self.attributes: Optional[str] = payload.get("attributes")
|
||||
self.messaging_binding: Optional[Dict[str, object]] = payload.get(
|
||||
"messaging_binding"
|
||||
)
|
||||
self.role_sid: Optional[str] = payload.get("role_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.last_read_message_index: Optional[int] = deserialize.integer(
|
||||
payload.get("last_read_message_index")
|
||||
)
|
||||
self.last_read_timestamp: Optional[str] = payload.get("last_read_timestamp")
|
||||
|
||||
self._solution = {
|
||||
"conversation_sid": conversation_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[ParticipantContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "ParticipantContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: ParticipantContext for this ParticipantInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = ParticipantContext(
|
||||
self._version,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ParticipantInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Deletes the ParticipantInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
)
|
||||
|
||||
async def delete_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ParticipantInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ParticipantInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
)
|
||||
|
||||
def fetch(self) -> "ParticipantInstance":
|
||||
"""
|
||||
Fetch the ParticipantInstance
|
||||
|
||||
|
||||
:returns: The fetched ParticipantInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "ParticipantInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ParticipantInstance
|
||||
|
||||
|
||||
:returns: The fetched ParticipantInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ParticipantInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
messaging_binding_proxy_address: Union[str, object] = values.unset,
|
||||
messaging_binding_projected_address: Union[str, object] = values.unset,
|
||||
identity: Union[str, object] = values.unset,
|
||||
last_read_message_index: Union[int, object] = values.unset,
|
||||
last_read_timestamp: Union[str, object] = values.unset,
|
||||
) -> "ParticipantInstance":
|
||||
"""
|
||||
Update the ParticipantInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated.
|
||||
:param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant.
|
||||
:param messaging_binding_proxy_address: The address of the Twilio phone number that the participant is in contact with. 'null' value will remove it.
|
||||
:param messaging_binding_projected_address: The address of the Twilio phone number that is used in Group MMS. 'null' value will remove it.
|
||||
:param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:param last_read_message_index: Index of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.
|
||||
:param last_read_timestamp: Timestamp of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.
|
||||
|
||||
:returns: The updated ParticipantInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
date_created=date_created,
|
||||
date_updated=date_updated,
|
||||
attributes=attributes,
|
||||
role_sid=role_sid,
|
||||
messaging_binding_proxy_address=messaging_binding_proxy_address,
|
||||
messaging_binding_projected_address=messaging_binding_projected_address,
|
||||
identity=identity,
|
||||
last_read_message_index=last_read_message_index,
|
||||
last_read_timestamp=last_read_timestamp,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ParticipantInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
messaging_binding_proxy_address: Union[str, object] = values.unset,
|
||||
messaging_binding_projected_address: Union[str, object] = values.unset,
|
||||
identity: Union[str, object] = values.unset,
|
||||
last_read_message_index: Union[int, object] = values.unset,
|
||||
last_read_timestamp: Union[str, object] = values.unset,
|
||||
) -> "ParticipantInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the ParticipantInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated.
|
||||
:param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant.
|
||||
:param messaging_binding_proxy_address: The address of the Twilio phone number that the participant is in contact with. 'null' value will remove it.
|
||||
:param messaging_binding_projected_address: The address of the Twilio phone number that is used in Group MMS. 'null' value will remove it.
|
||||
:param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:param last_read_message_index: Index of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.
|
||||
:param last_read_timestamp: Timestamp of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.
|
||||
|
||||
:returns: The updated ParticipantInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
date_created=date_created,
|
||||
date_updated=date_updated,
|
||||
attributes=attributes,
|
||||
role_sid=role_sid,
|
||||
messaging_binding_proxy_address=messaging_binding_proxy_address,
|
||||
messaging_binding_projected_address=messaging_binding_projected_address,
|
||||
identity=identity,
|
||||
last_read_message_index=last_read_message_index,
|
||||
last_read_timestamp=last_read_timestamp,
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.ParticipantInstance {}>".format(context)
|
||||
|
||||
|
||||
class ParticipantContext(InstanceContext):
|
||||
def __init__(self, version: Version, conversation_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the ParticipantContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this participant.
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"conversation_sid": conversation_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Conversations/{conversation_sid}/Participants/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ParticipantInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Deletes the ParticipantInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
return self._version.delete(method="DELETE", uri=self._uri, headers=headers)
|
||||
|
||||
async def delete_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ParticipantInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ParticipantInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
return await self._version.delete_async(
|
||||
method="DELETE", uri=self._uri, headers=headers
|
||||
)
|
||||
|
||||
def fetch(self) -> ParticipantInstance:
|
||||
"""
|
||||
Fetch the ParticipantInstance
|
||||
|
||||
|
||||
:returns: The fetched ParticipantInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ParticipantInstance(
|
||||
self._version,
|
||||
payload,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> ParticipantInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ParticipantInstance
|
||||
|
||||
|
||||
:returns: The fetched ParticipantInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ParticipantInstance(
|
||||
self._version,
|
||||
payload,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ParticipantInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
messaging_binding_proxy_address: Union[str, object] = values.unset,
|
||||
messaging_binding_projected_address: Union[str, object] = values.unset,
|
||||
identity: Union[str, object] = values.unset,
|
||||
last_read_message_index: Union[int, object] = values.unset,
|
||||
last_read_timestamp: Union[str, object] = values.unset,
|
||||
) -> ParticipantInstance:
|
||||
"""
|
||||
Update the ParticipantInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated.
|
||||
:param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant.
|
||||
:param messaging_binding_proxy_address: The address of the Twilio phone number that the participant is in contact with. 'null' value will remove it.
|
||||
:param messaging_binding_projected_address: The address of the Twilio phone number that is used in Group MMS. 'null' value will remove it.
|
||||
:param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:param last_read_message_index: Index of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.
|
||||
:param last_read_timestamp: Timestamp of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.
|
||||
|
||||
:returns: The updated ParticipantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateUpdated": serialize.iso8601_datetime(date_updated),
|
||||
"Attributes": attributes,
|
||||
"RoleSid": role_sid,
|
||||
"MessagingBinding.ProxyAddress": messaging_binding_proxy_address,
|
||||
"MessagingBinding.ProjectedAddress": messaging_binding_projected_address,
|
||||
"Identity": identity,
|
||||
"LastReadMessageIndex": last_read_message_index,
|
||||
"LastReadTimestamp": last_read_timestamp,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return ParticipantInstance(
|
||||
self._version,
|
||||
payload,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ParticipantInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
messaging_binding_proxy_address: Union[str, object] = values.unset,
|
||||
messaging_binding_projected_address: Union[str, object] = values.unset,
|
||||
identity: Union[str, object] = values.unset,
|
||||
last_read_message_index: Union[int, object] = values.unset,
|
||||
last_read_timestamp: Union[str, object] = values.unset,
|
||||
) -> ParticipantInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the ParticipantInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated.
|
||||
:param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant.
|
||||
:param messaging_binding_proxy_address: The address of the Twilio phone number that the participant is in contact with. 'null' value will remove it.
|
||||
:param messaging_binding_projected_address: The address of the Twilio phone number that is used in Group MMS. 'null' value will remove it.
|
||||
:param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:param last_read_message_index: Index of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.
|
||||
:param last_read_timestamp: Timestamp of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.
|
||||
|
||||
:returns: The updated ParticipantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateUpdated": serialize.iso8601_datetime(date_updated),
|
||||
"Attributes": attributes,
|
||||
"RoleSid": role_sid,
|
||||
"MessagingBinding.ProxyAddress": messaging_binding_proxy_address,
|
||||
"MessagingBinding.ProjectedAddress": messaging_binding_projected_address,
|
||||
"Identity": identity,
|
||||
"LastReadMessageIndex": last_read_message_index,
|
||||
"LastReadTimestamp": last_read_timestamp,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return ParticipantInstance(
|
||||
self._version,
|
||||
payload,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.ParticipantContext {}>".format(context)
|
||||
|
||||
|
||||
class ParticipantPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> ParticipantInstance:
|
||||
"""
|
||||
Build an instance of ParticipantInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return ParticipantInstance(
|
||||
self._version, payload, conversation_sid=self._solution["conversation_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.ParticipantPage>"
|
||||
|
||||
|
||||
class ParticipantList(ListResource):
|
||||
def __init__(self, version: Version, conversation_sid: str):
|
||||
"""
|
||||
Initialize the ParticipantList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for participants.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"conversation_sid": conversation_sid,
|
||||
}
|
||||
self._uri = "/Conversations/{conversation_sid}/Participants".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ParticipantInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
identity: Union[str, object] = values.unset,
|
||||
messaging_binding_address: Union[str, object] = values.unset,
|
||||
messaging_binding_proxy_address: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
messaging_binding_projected_address: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
) -> ParticipantInstance:
|
||||
"""
|
||||
Create the ParticipantInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:param messaging_binding_address: The address of the participant's device, e.g. a phone or WhatsApp number. Together with the Proxy address, this determines a participant uniquely. This field (with proxy_address) is only null when the participant is interacting from an SDK endpoint (see the 'identity' field).
|
||||
:param messaging_binding_proxy_address: The address of the Twilio phone number (or WhatsApp number) that the participant is in contact with. This field, together with participant address, is only null when the participant is interacting from an SDK endpoint (see the 'identity' field).
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated.
|
||||
:param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param messaging_binding_projected_address: The address of the Twilio phone number that is used in Group MMS. Communication mask for the Conversation participant with Identity.
|
||||
:param role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant.
|
||||
|
||||
:returns: The created ParticipantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Identity": identity,
|
||||
"MessagingBinding.Address": messaging_binding_address,
|
||||
"MessagingBinding.ProxyAddress": messaging_binding_proxy_address,
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateUpdated": serialize.iso8601_datetime(date_updated),
|
||||
"Attributes": attributes,
|
||||
"MessagingBinding.ProjectedAddress": messaging_binding_projected_address,
|
||||
"RoleSid": role_sid,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
payload = self._version.create(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return ParticipantInstance(
|
||||
self._version, payload, conversation_sid=self._solution["conversation_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ParticipantInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
identity: Union[str, object] = values.unset,
|
||||
messaging_binding_address: Union[str, object] = values.unset,
|
||||
messaging_binding_proxy_address: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
messaging_binding_projected_address: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
) -> ParticipantInstance:
|
||||
"""
|
||||
Asynchronously create the ParticipantInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:param messaging_binding_address: The address of the participant's device, e.g. a phone or WhatsApp number. Together with the Proxy address, this determines a participant uniquely. This field (with proxy_address) is only null when the participant is interacting from an SDK endpoint (see the 'identity' field).
|
||||
:param messaging_binding_proxy_address: The address of the Twilio phone number (or WhatsApp number) that the participant is in contact with. This field, together with participant address, is only null when the participant is interacting from an SDK endpoint (see the 'identity' field).
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated.
|
||||
:param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param messaging_binding_projected_address: The address of the Twilio phone number that is used in Group MMS. Communication mask for the Conversation participant with Identity.
|
||||
:param role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant.
|
||||
|
||||
:returns: The created ParticipantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Identity": identity,
|
||||
"MessagingBinding.Address": messaging_binding_address,
|
||||
"MessagingBinding.ProxyAddress": messaging_binding_proxy_address,
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateUpdated": serialize.iso8601_datetime(date_updated),
|
||||
"Attributes": attributes,
|
||||
"MessagingBinding.ProjectedAddress": messaging_binding_projected_address,
|
||||
"RoleSid": role_sid,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
payload = await self._version.create_async(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return ParticipantInstance(
|
||||
self._version, payload, conversation_sid=self._solution["conversation_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[ParticipantInstance]:
|
||||
"""
|
||||
Streams ParticipantInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[ParticipantInstance]:
|
||||
"""
|
||||
Asynchronously streams ParticipantInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ParticipantInstance]:
|
||||
"""
|
||||
Lists ParticipantInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ParticipantInstance]:
|
||||
"""
|
||||
Asynchronously lists ParticipantInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ParticipantPage:
|
||||
"""
|
||||
Retrieve a single page of ParticipantInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of ParticipantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return ParticipantPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ParticipantPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of ParticipantInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of ParticipantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return ParticipantPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> ParticipantPage:
|
||||
"""
|
||||
Retrieve a specific page of ParticipantInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ParticipantInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return ParticipantPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> ParticipantPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of ParticipantInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ParticipantInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return ParticipantPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> ParticipantContext:
|
||||
"""
|
||||
Constructs a ParticipantContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return ParticipantContext(
|
||||
self._version, conversation_sid=self._solution["conversation_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> ParticipantContext:
|
||||
"""
|
||||
Constructs a ParticipantContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return ParticipantContext(
|
||||
self._version, conversation_sid=self._solution["conversation_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.ParticipantList>"
|
||||
+723
@@ -0,0 +1,723 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
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.page import Page
|
||||
|
||||
|
||||
class WebhookInstance(InstanceResource):
|
||||
class Method(object):
|
||||
GET = "GET"
|
||||
POST = "POST"
|
||||
|
||||
class Target(object):
|
||||
WEBHOOK = "webhook"
|
||||
TRIGGER = "trigger"
|
||||
STUDIO = "studio"
|
||||
|
||||
"""
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this conversation.
|
||||
:ivar conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this webhook.
|
||||
:ivar target: The target of this webhook: `webhook`, `studio`, `trigger`
|
||||
:ivar url: An absolute API resource URL for this webhook.
|
||||
:ivar configuration: The configuration of this webhook. Is defined based on target.
|
||||
:ivar date_created: The date that this resource was created.
|
||||
:ivar date_updated: The date that this resource was last updated.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
conversation_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.conversation_sid: Optional[str] = payload.get("conversation_sid")
|
||||
self.target: Optional[str] = payload.get("target")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.configuration: Optional[Dict[str, object]] = payload.get("configuration")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"conversation_sid": conversation_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[WebhookContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "WebhookContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: WebhookContext for this WebhookInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = WebhookContext(
|
||||
self._version,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the WebhookInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the WebhookInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "WebhookInstance":
|
||||
"""
|
||||
Fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "WebhookInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
configuration_url: Union[str, object] = values.unset,
|
||||
configuration_method: Union["WebhookInstance.Method", object] = values.unset,
|
||||
configuration_filters: Union[List[str], object] = values.unset,
|
||||
configuration_triggers: Union[List[str], object] = values.unset,
|
||||
configuration_flow_sid: Union[str, object] = values.unset,
|
||||
) -> "WebhookInstance":
|
||||
"""
|
||||
Update the WebhookInstance
|
||||
|
||||
:param configuration_url: The absolute url the webhook request should be sent to.
|
||||
:param configuration_method:
|
||||
:param configuration_filters: The list of events, firing webhook event for this Conversation.
|
||||
:param configuration_triggers: The list of keywords, firing webhook event for this Conversation.
|
||||
:param configuration_flow_sid: The studio flow SID, where the webhook should be sent to.
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
configuration_url=configuration_url,
|
||||
configuration_method=configuration_method,
|
||||
configuration_filters=configuration_filters,
|
||||
configuration_triggers=configuration_triggers,
|
||||
configuration_flow_sid=configuration_flow_sid,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
configuration_url: Union[str, object] = values.unset,
|
||||
configuration_method: Union["WebhookInstance.Method", object] = values.unset,
|
||||
configuration_filters: Union[List[str], object] = values.unset,
|
||||
configuration_triggers: Union[List[str], object] = values.unset,
|
||||
configuration_flow_sid: Union[str, object] = values.unset,
|
||||
) -> "WebhookInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the WebhookInstance
|
||||
|
||||
:param configuration_url: The absolute url the webhook request should be sent to.
|
||||
:param configuration_method:
|
||||
:param configuration_filters: The list of events, firing webhook event for this Conversation.
|
||||
:param configuration_triggers: The list of keywords, firing webhook event for this Conversation.
|
||||
:param configuration_flow_sid: The studio flow SID, where the webhook should be sent to.
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
configuration_url=configuration_url,
|
||||
configuration_method=configuration_method,
|
||||
configuration_filters=configuration_filters,
|
||||
configuration_triggers=configuration_triggers,
|
||||
configuration_flow_sid=configuration_flow_sid,
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.WebhookInstance {}>".format(context)
|
||||
|
||||
|
||||
class WebhookContext(InstanceContext):
|
||||
def __init__(self, version: Version, conversation_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the WebhookContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this webhook.
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"conversation_sid": conversation_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Conversations/{conversation_sid}/Webhooks/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the WebhookInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the WebhookInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> WebhookInstance:
|
||||
"""
|
||||
Fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> WebhookInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
configuration_url: Union[str, object] = values.unset,
|
||||
configuration_method: Union["WebhookInstance.Method", object] = values.unset,
|
||||
configuration_filters: Union[List[str], object] = values.unset,
|
||||
configuration_triggers: Union[List[str], object] = values.unset,
|
||||
configuration_flow_sid: Union[str, object] = values.unset,
|
||||
) -> WebhookInstance:
|
||||
"""
|
||||
Update the WebhookInstance
|
||||
|
||||
:param configuration_url: The absolute url the webhook request should be sent to.
|
||||
:param configuration_method:
|
||||
:param configuration_filters: The list of events, firing webhook event for this Conversation.
|
||||
:param configuration_triggers: The list of keywords, firing webhook event for this Conversation.
|
||||
:param configuration_flow_sid: The studio flow SID, where the webhook should be sent to.
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Configuration.Url": configuration_url,
|
||||
"Configuration.Method": configuration_method,
|
||||
"Configuration.Filters": serialize.map(
|
||||
configuration_filters, lambda e: e
|
||||
),
|
||||
"Configuration.Triggers": serialize.map(
|
||||
configuration_triggers, lambda e: e
|
||||
),
|
||||
"Configuration.FlowSid": configuration_flow_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
configuration_url: Union[str, object] = values.unset,
|
||||
configuration_method: Union["WebhookInstance.Method", object] = values.unset,
|
||||
configuration_filters: Union[List[str], object] = values.unset,
|
||||
configuration_triggers: Union[List[str], object] = values.unset,
|
||||
configuration_flow_sid: Union[str, object] = values.unset,
|
||||
) -> WebhookInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the WebhookInstance
|
||||
|
||||
:param configuration_url: The absolute url the webhook request should be sent to.
|
||||
:param configuration_method:
|
||||
:param configuration_filters: The list of events, firing webhook event for this Conversation.
|
||||
:param configuration_triggers: The list of keywords, firing webhook event for this Conversation.
|
||||
:param configuration_flow_sid: The studio flow SID, where the webhook should be sent to.
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Configuration.Url": configuration_url,
|
||||
"Configuration.Method": configuration_method,
|
||||
"Configuration.Filters": serialize.map(
|
||||
configuration_filters, lambda e: e
|
||||
),
|
||||
"Configuration.Triggers": serialize.map(
|
||||
configuration_triggers, lambda e: e
|
||||
),
|
||||
"Configuration.FlowSid": configuration_flow_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.WebhookContext {}>".format(context)
|
||||
|
||||
|
||||
class WebhookPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> WebhookInstance:
|
||||
"""
|
||||
Build an instance of WebhookInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return WebhookInstance(
|
||||
self._version, payload, conversation_sid=self._solution["conversation_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.WebhookPage>"
|
||||
|
||||
|
||||
class WebhookList(ListResource):
|
||||
def __init__(self, version: Version, conversation_sid: str):
|
||||
"""
|
||||
Initialize the WebhookList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this webhook.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"conversation_sid": conversation_sid,
|
||||
}
|
||||
self._uri = "/Conversations/{conversation_sid}/Webhooks".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self,
|
||||
target: "WebhookInstance.Target",
|
||||
configuration_url: Union[str, object] = values.unset,
|
||||
configuration_method: Union["WebhookInstance.Method", object] = values.unset,
|
||||
configuration_filters: Union[List[str], object] = values.unset,
|
||||
configuration_triggers: Union[List[str], object] = values.unset,
|
||||
configuration_flow_sid: Union[str, object] = values.unset,
|
||||
configuration_replay_after: Union[int, object] = values.unset,
|
||||
) -> WebhookInstance:
|
||||
"""
|
||||
Create the WebhookInstance
|
||||
|
||||
:param target:
|
||||
:param configuration_url: The absolute url the webhook request should be sent to.
|
||||
:param configuration_method:
|
||||
:param configuration_filters: The list of events, firing webhook event for this Conversation.
|
||||
:param configuration_triggers: The list of keywords, firing webhook event for this Conversation.
|
||||
:param configuration_flow_sid: The studio flow SID, where the webhook should be sent to.
|
||||
:param configuration_replay_after: The message index for which and it's successors the webhook will be replayed. Not set by default
|
||||
|
||||
:returns: The created WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Target": target,
|
||||
"Configuration.Url": configuration_url,
|
||||
"Configuration.Method": configuration_method,
|
||||
"Configuration.Filters": serialize.map(
|
||||
configuration_filters, lambda e: e
|
||||
),
|
||||
"Configuration.Triggers": serialize.map(
|
||||
configuration_triggers, lambda e: e
|
||||
),
|
||||
"Configuration.FlowSid": configuration_flow_sid,
|
||||
"Configuration.ReplayAfter": configuration_replay_after,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version, payload, conversation_sid=self._solution["conversation_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
target: "WebhookInstance.Target",
|
||||
configuration_url: Union[str, object] = values.unset,
|
||||
configuration_method: Union["WebhookInstance.Method", object] = values.unset,
|
||||
configuration_filters: Union[List[str], object] = values.unset,
|
||||
configuration_triggers: Union[List[str], object] = values.unset,
|
||||
configuration_flow_sid: Union[str, object] = values.unset,
|
||||
configuration_replay_after: Union[int, object] = values.unset,
|
||||
) -> WebhookInstance:
|
||||
"""
|
||||
Asynchronously create the WebhookInstance
|
||||
|
||||
:param target:
|
||||
:param configuration_url: The absolute url the webhook request should be sent to.
|
||||
:param configuration_method:
|
||||
:param configuration_filters: The list of events, firing webhook event for this Conversation.
|
||||
:param configuration_triggers: The list of keywords, firing webhook event for this Conversation.
|
||||
:param configuration_flow_sid: The studio flow SID, where the webhook should be sent to.
|
||||
:param configuration_replay_after: The message index for which and it's successors the webhook will be replayed. Not set by default
|
||||
|
||||
:returns: The created WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Target": target,
|
||||
"Configuration.Url": configuration_url,
|
||||
"Configuration.Method": configuration_method,
|
||||
"Configuration.Filters": serialize.map(
|
||||
configuration_filters, lambda e: e
|
||||
),
|
||||
"Configuration.Triggers": serialize.map(
|
||||
configuration_triggers, lambda e: e
|
||||
),
|
||||
"Configuration.FlowSid": configuration_flow_sid,
|
||||
"Configuration.ReplayAfter": configuration_replay_after,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version, payload, conversation_sid=self._solution["conversation_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[WebhookInstance]:
|
||||
"""
|
||||
Streams WebhookInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[WebhookInstance]:
|
||||
"""
|
||||
Asynchronously streams WebhookInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[WebhookInstance]:
|
||||
"""
|
||||
Lists WebhookInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[WebhookInstance]:
|
||||
"""
|
||||
Asynchronously lists WebhookInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> WebhookPage:
|
||||
"""
|
||||
Retrieve a single page of WebhookInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return WebhookPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> WebhookPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of WebhookInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return WebhookPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> WebhookPage:
|
||||
"""
|
||||
Retrieve a specific page of WebhookInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of WebhookInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return WebhookPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> WebhookPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of WebhookInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of WebhookInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return WebhookPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> WebhookContext:
|
||||
"""
|
||||
Constructs a WebhookContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return WebhookContext(
|
||||
self._version, conversation_sid=self._solution["conversation_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> WebhookContext:
|
||||
"""
|
||||
Constructs a WebhookContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return WebhookContext(
|
||||
self._version, conversation_sid=self._solution["conversation_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.WebhookList>"
|
||||
@@ -0,0 +1,688 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
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.page import Page
|
||||
|
||||
|
||||
class CredentialInstance(InstanceResource):
|
||||
class PushType(object):
|
||||
APN = "apn"
|
||||
GCM = "gcm"
|
||||
FCM = "fcm"
|
||||
|
||||
"""
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this credential.
|
||||
:ivar friendly_name: The human-readable name of this credential, limited to 64 characters. Optional.
|
||||
:ivar type:
|
||||
:ivar sandbox: [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
|
||||
:ivar date_created: The date that this resource was created.
|
||||
:ivar date_updated: The date that this resource was last updated.
|
||||
:ivar url: An absolute API resource URL for this credential.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.type: Optional["CredentialInstance.PushType"] = payload.get("type")
|
||||
self.sandbox: Optional[str] = payload.get("sandbox")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[CredentialContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "CredentialContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: CredentialContext for this CredentialInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = CredentialContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the CredentialInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the CredentialInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "CredentialInstance":
|
||||
"""
|
||||
Fetch the CredentialInstance
|
||||
|
||||
|
||||
:returns: The fetched CredentialInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "CredentialInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the CredentialInstance
|
||||
|
||||
|
||||
:returns: The fetched CredentialInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
type: Union["CredentialInstance.PushType", object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
certificate: Union[str, object] = values.unset,
|
||||
private_key: Union[str, object] = values.unset,
|
||||
sandbox: Union[bool, object] = values.unset,
|
||||
api_key: Union[str, object] = values.unset,
|
||||
secret: Union[str, object] = values.unset,
|
||||
) -> "CredentialInstance":
|
||||
"""
|
||||
Update the CredentialInstance
|
||||
|
||||
:param type:
|
||||
:param friendly_name: A descriptive string that you create to describe the new resource. It can be up to 64 characters long.
|
||||
:param certificate: [APN only] The URL encoded representation of the certificate. For example, `-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----`.
|
||||
:param private_key: [APN only] The URL encoded representation of the private key. For example, `-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----`.
|
||||
:param sandbox: [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
|
||||
:param api_key: [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential.
|
||||
:param secret: [FCM only] The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging.
|
||||
|
||||
:returns: The updated CredentialInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
type=type,
|
||||
friendly_name=friendly_name,
|
||||
certificate=certificate,
|
||||
private_key=private_key,
|
||||
sandbox=sandbox,
|
||||
api_key=api_key,
|
||||
secret=secret,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
type: Union["CredentialInstance.PushType", object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
certificate: Union[str, object] = values.unset,
|
||||
private_key: Union[str, object] = values.unset,
|
||||
sandbox: Union[bool, object] = values.unset,
|
||||
api_key: Union[str, object] = values.unset,
|
||||
secret: Union[str, object] = values.unset,
|
||||
) -> "CredentialInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the CredentialInstance
|
||||
|
||||
:param type:
|
||||
:param friendly_name: A descriptive string that you create to describe the new resource. It can be up to 64 characters long.
|
||||
:param certificate: [APN only] The URL encoded representation of the certificate. For example, `-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----`.
|
||||
:param private_key: [APN only] The URL encoded representation of the private key. For example, `-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----`.
|
||||
:param sandbox: [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
|
||||
:param api_key: [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential.
|
||||
:param secret: [FCM only] The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging.
|
||||
|
||||
:returns: The updated CredentialInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
type=type,
|
||||
friendly_name=friendly_name,
|
||||
certificate=certificate,
|
||||
private_key=private_key,
|
||||
sandbox=sandbox,
|
||||
api_key=api_key,
|
||||
secret=secret,
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.CredentialInstance {}>".format(context)
|
||||
|
||||
|
||||
class CredentialContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the CredentialContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Credentials/{sid}".format(**self._solution)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the CredentialInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the CredentialInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> CredentialInstance:
|
||||
"""
|
||||
Fetch the CredentialInstance
|
||||
|
||||
|
||||
:returns: The fetched CredentialInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return CredentialInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> CredentialInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the CredentialInstance
|
||||
|
||||
|
||||
:returns: The fetched CredentialInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return CredentialInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
type: Union["CredentialInstance.PushType", object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
certificate: Union[str, object] = values.unset,
|
||||
private_key: Union[str, object] = values.unset,
|
||||
sandbox: Union[bool, object] = values.unset,
|
||||
api_key: Union[str, object] = values.unset,
|
||||
secret: Union[str, object] = values.unset,
|
||||
) -> CredentialInstance:
|
||||
"""
|
||||
Update the CredentialInstance
|
||||
|
||||
:param type:
|
||||
:param friendly_name: A descriptive string that you create to describe the new resource. It can be up to 64 characters long.
|
||||
:param certificate: [APN only] The URL encoded representation of the certificate. For example, `-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----`.
|
||||
:param private_key: [APN only] The URL encoded representation of the private key. For example, `-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----`.
|
||||
:param sandbox: [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
|
||||
:param api_key: [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential.
|
||||
:param secret: [FCM only] The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging.
|
||||
|
||||
:returns: The updated CredentialInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Type": type,
|
||||
"FriendlyName": friendly_name,
|
||||
"Certificate": certificate,
|
||||
"PrivateKey": private_key,
|
||||
"Sandbox": sandbox,
|
||||
"ApiKey": api_key,
|
||||
"Secret": secret,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return CredentialInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
type: Union["CredentialInstance.PushType", object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
certificate: Union[str, object] = values.unset,
|
||||
private_key: Union[str, object] = values.unset,
|
||||
sandbox: Union[bool, object] = values.unset,
|
||||
api_key: Union[str, object] = values.unset,
|
||||
secret: Union[str, object] = values.unset,
|
||||
) -> CredentialInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the CredentialInstance
|
||||
|
||||
:param type:
|
||||
:param friendly_name: A descriptive string that you create to describe the new resource. It can be up to 64 characters long.
|
||||
:param certificate: [APN only] The URL encoded representation of the certificate. For example, `-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----`.
|
||||
:param private_key: [APN only] The URL encoded representation of the private key. For example, `-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----`.
|
||||
:param sandbox: [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
|
||||
:param api_key: [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential.
|
||||
:param secret: [FCM only] The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging.
|
||||
|
||||
:returns: The updated CredentialInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Type": type,
|
||||
"FriendlyName": friendly_name,
|
||||
"Certificate": certificate,
|
||||
"PrivateKey": private_key,
|
||||
"Sandbox": sandbox,
|
||||
"ApiKey": api_key,
|
||||
"Secret": secret,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return CredentialInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
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 "<Twilio.Conversations.V1.CredentialContext {}>".format(context)
|
||||
|
||||
|
||||
class CredentialPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> CredentialInstance:
|
||||
"""
|
||||
Build an instance of CredentialInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return CredentialInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.CredentialPage>"
|
||||
|
||||
|
||||
class CredentialList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the CredentialList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/Credentials"
|
||||
|
||||
def create(
|
||||
self,
|
||||
type: "CredentialInstance.PushType",
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
certificate: Union[str, object] = values.unset,
|
||||
private_key: Union[str, object] = values.unset,
|
||||
sandbox: Union[bool, object] = values.unset,
|
||||
api_key: Union[str, object] = values.unset,
|
||||
secret: Union[str, object] = values.unset,
|
||||
) -> CredentialInstance:
|
||||
"""
|
||||
Create the CredentialInstance
|
||||
|
||||
:param type:
|
||||
:param friendly_name: A descriptive string that you create to describe the new resource. It can be up to 64 characters long.
|
||||
:param certificate: [APN only] The URL encoded representation of the certificate. For example, `-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----`.
|
||||
:param private_key: [APN only] The URL encoded representation of the private key. For example, `-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----`.
|
||||
:param sandbox: [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
|
||||
:param api_key: [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential.
|
||||
:param secret: [FCM only] The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging.
|
||||
|
||||
:returns: The created CredentialInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Type": type,
|
||||
"FriendlyName": friendly_name,
|
||||
"Certificate": certificate,
|
||||
"PrivateKey": private_key,
|
||||
"Sandbox": sandbox,
|
||||
"ApiKey": api_key,
|
||||
"Secret": secret,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return CredentialInstance(self._version, payload)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
type: "CredentialInstance.PushType",
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
certificate: Union[str, object] = values.unset,
|
||||
private_key: Union[str, object] = values.unset,
|
||||
sandbox: Union[bool, object] = values.unset,
|
||||
api_key: Union[str, object] = values.unset,
|
||||
secret: Union[str, object] = values.unset,
|
||||
) -> CredentialInstance:
|
||||
"""
|
||||
Asynchronously create the CredentialInstance
|
||||
|
||||
:param type:
|
||||
:param friendly_name: A descriptive string that you create to describe the new resource. It can be up to 64 characters long.
|
||||
:param certificate: [APN only] The URL encoded representation of the certificate. For example, `-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----`.
|
||||
:param private_key: [APN only] The URL encoded representation of the private key. For example, `-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----`.
|
||||
:param sandbox: [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
|
||||
:param api_key: [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential.
|
||||
:param secret: [FCM only] The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging.
|
||||
|
||||
:returns: The created CredentialInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Type": type,
|
||||
"FriendlyName": friendly_name,
|
||||
"Certificate": certificate,
|
||||
"PrivateKey": private_key,
|
||||
"Sandbox": sandbox,
|
||||
"ApiKey": api_key,
|
||||
"Secret": secret,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return CredentialInstance(self._version, payload)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[CredentialInstance]:
|
||||
"""
|
||||
Streams CredentialInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[CredentialInstance]:
|
||||
"""
|
||||
Asynchronously streams CredentialInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[CredentialInstance]:
|
||||
"""
|
||||
Lists CredentialInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[CredentialInstance]:
|
||||
"""
|
||||
Asynchronously lists CredentialInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> CredentialPage:
|
||||
"""
|
||||
Retrieve a single page of CredentialInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of CredentialInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return CredentialPage(self._version, response)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> CredentialPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of CredentialInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of CredentialInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return CredentialPage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> CredentialPage:
|
||||
"""
|
||||
Retrieve a specific page of CredentialInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of CredentialInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return CredentialPage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> CredentialPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of CredentialInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of CredentialInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return CredentialPage(self._version, response)
|
||||
|
||||
def get(self, sid: str) -> CredentialContext:
|
||||
"""
|
||||
Constructs a CredentialContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return CredentialContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> CredentialContext:
|
||||
"""
|
||||
Constructs a CredentialContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return CredentialContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.CredentialList>"
|
||||
+354
@@ -0,0 +1,354 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class ParticipantConversationInstance(InstanceResource):
|
||||
class State(object):
|
||||
INACTIVE = "inactive"
|
||||
ACTIVE = "active"
|
||||
CLOSED = "closed"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this conversation.
|
||||
:ivar chat_service_sid: The unique ID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation belongs to.
|
||||
:ivar participant_sid: The unique ID of the [Participant](https://www.twilio.com/docs/conversations/api/conversation-participant-resource).
|
||||
:ivar participant_user_sid: The unique string that identifies the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource).
|
||||
:ivar participant_identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:ivar participant_messaging_binding: Information about how this participant exchanges messages with the conversation. A JSON parameter consisting of type and address fields of the participant.
|
||||
:ivar conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) this Participant belongs to.
|
||||
:ivar conversation_unique_name: An application-defined string that uniquely identifies the Conversation resource.
|
||||
:ivar conversation_friendly_name: The human-readable name of this conversation, limited to 256 characters. Optional.
|
||||
:ivar conversation_attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \"{}\" will be returned.
|
||||
:ivar conversation_date_created: The date that this conversation was created, given in ISO 8601 format.
|
||||
:ivar conversation_date_updated: The date that this conversation was last updated, given in ISO 8601 format.
|
||||
:ivar conversation_created_by: Identity of the creator of this Conversation.
|
||||
:ivar conversation_state:
|
||||
:ivar conversation_timers: Timer date values representing state update for this conversation.
|
||||
:ivar links: Contains absolute URLs to access the [participant](https://www.twilio.com/docs/conversations/api/conversation-participant-resource) and [conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) of this conversation.
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any]):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.chat_service_sid: Optional[str] = payload.get("chat_service_sid")
|
||||
self.participant_sid: Optional[str] = payload.get("participant_sid")
|
||||
self.participant_user_sid: Optional[str] = payload.get("participant_user_sid")
|
||||
self.participant_identity: Optional[str] = payload.get("participant_identity")
|
||||
self.participant_messaging_binding: Optional[Dict[str, object]] = payload.get(
|
||||
"participant_messaging_binding"
|
||||
)
|
||||
self.conversation_sid: Optional[str] = payload.get("conversation_sid")
|
||||
self.conversation_unique_name: Optional[str] = payload.get(
|
||||
"conversation_unique_name"
|
||||
)
|
||||
self.conversation_friendly_name: Optional[str] = payload.get(
|
||||
"conversation_friendly_name"
|
||||
)
|
||||
self.conversation_attributes: Optional[str] = payload.get(
|
||||
"conversation_attributes"
|
||||
)
|
||||
self.conversation_date_created: Optional[
|
||||
datetime
|
||||
] = deserialize.iso8601_datetime(payload.get("conversation_date_created"))
|
||||
self.conversation_date_updated: Optional[
|
||||
datetime
|
||||
] = deserialize.iso8601_datetime(payload.get("conversation_date_updated"))
|
||||
self.conversation_created_by: Optional[str] = payload.get(
|
||||
"conversation_created_by"
|
||||
)
|
||||
self.conversation_state: Optional[
|
||||
"ParticipantConversationInstance.State"
|
||||
] = payload.get("conversation_state")
|
||||
self.conversation_timers: Optional[Dict[str, object]] = payload.get(
|
||||
"conversation_timers"
|
||||
)
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
|
||||
return "<Twilio.Conversations.V1.ParticipantConversationInstance>"
|
||||
|
||||
|
||||
class ParticipantConversationPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> ParticipantConversationInstance:
|
||||
"""
|
||||
Build an instance of ParticipantConversationInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return ParticipantConversationInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.ParticipantConversationPage>"
|
||||
|
||||
|
||||
class ParticipantConversationList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the ParticipantConversationList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/ParticipantConversations"
|
||||
|
||||
def stream(
|
||||
self,
|
||||
identity: Union[str, object] = values.unset,
|
||||
address: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[ParticipantConversationInstance]:
|
||||
"""
|
||||
Streams ParticipantConversationInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:param str address: A unique string identifier for the conversation participant who's not a Conversation User. This parameter could be found in messaging_binding.address field of Participant resource. It should be url-encoded.
|
||||
: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(
|
||||
identity=identity, address=address, page_size=limits["page_size"]
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
identity: Union[str, object] = values.unset,
|
||||
address: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[ParticipantConversationInstance]:
|
||||
"""
|
||||
Asynchronously streams ParticipantConversationInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:param str address: A unique string identifier for the conversation participant who's not a Conversation User. This parameter could be found in messaging_binding.address field of Participant resource. It should be url-encoded.
|
||||
: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(
|
||||
identity=identity, address=address, page_size=limits["page_size"]
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
identity: Union[str, object] = values.unset,
|
||||
address: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ParticipantConversationInstance]:
|
||||
"""
|
||||
Lists ParticipantConversationInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:param str address: A unique string identifier for the conversation participant who's not a Conversation User. This parameter could be found in messaging_binding.address field of Participant resource. It should be url-encoded.
|
||||
: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(
|
||||
identity=identity,
|
||||
address=address,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
identity: Union[str, object] = values.unset,
|
||||
address: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ParticipantConversationInstance]:
|
||||
"""
|
||||
Asynchronously lists ParticipantConversationInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:param str address: A unique string identifier for the conversation participant who's not a Conversation User. This parameter could be found in messaging_binding.address field of Participant resource. It should be url-encoded.
|
||||
: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(
|
||||
identity=identity,
|
||||
address=address,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
identity: Union[str, object] = values.unset,
|
||||
address: 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,
|
||||
) -> ParticipantConversationPage:
|
||||
"""
|
||||
Retrieve a single page of ParticipantConversationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:param address: A unique string identifier for the conversation participant who's not a Conversation User. This parameter could be found in messaging_binding.address field of Participant resource. It should be url-encoded.
|
||||
: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: Page of ParticipantConversationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Identity": identity,
|
||||
"Address": address,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return ParticipantConversationPage(self._version, response)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
identity: Union[str, object] = values.unset,
|
||||
address: 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,
|
||||
) -> ParticipantConversationPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of ParticipantConversationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:param address: A unique string identifier for the conversation participant who's not a Conversation User. This parameter could be found in messaging_binding.address field of Participant resource. It should be url-encoded.
|
||||
: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: Page of ParticipantConversationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Identity": identity,
|
||||
"Address": address,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return ParticipantConversationPage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> ParticipantConversationPage:
|
||||
"""
|
||||
Retrieve a specific page of ParticipantConversationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ParticipantConversationInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return ParticipantConversationPage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> ParticipantConversationPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of ParticipantConversationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ParticipantConversationInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return ParticipantConversationPage(self._version, response)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.ParticipantConversationList>"
|
||||
@@ -0,0 +1,575 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
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.page import Page
|
||||
|
||||
|
||||
class RoleInstance(InstanceResource):
|
||||
class RoleType(object):
|
||||
CONVERSATION = "conversation"
|
||||
SERVICE = "service"
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that we created to identify the Role resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Role resource.
|
||||
:ivar chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Role resource is associated with.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar type:
|
||||
:ivar permissions: An array of the permissions the role has been granted.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar url: An absolute API resource URL for this user role.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.chat_service_sid: Optional[str] = payload.get("chat_service_sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.type: Optional["RoleInstance.RoleType"] = payload.get("type")
|
||||
self.permissions: Optional[List[str]] = payload.get("permissions")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[RoleContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "RoleContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: RoleContext for this RoleInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = RoleContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the RoleInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the RoleInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "RoleInstance":
|
||||
"""
|
||||
Fetch the RoleInstance
|
||||
|
||||
|
||||
:returns: The fetched RoleInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "RoleInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the RoleInstance
|
||||
|
||||
|
||||
:returns: The fetched RoleInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(self, permission: List[str]) -> "RoleInstance":
|
||||
"""
|
||||
Update the RoleInstance
|
||||
|
||||
:param permission: A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. Note that the update action replaces all previously assigned permissions with those defined in the update action. To remove a permission, do not include it in the subsequent update action. The values for this parameter depend on the role's `type`.
|
||||
|
||||
:returns: The updated RoleInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
permission=permission,
|
||||
)
|
||||
|
||||
async def update_async(self, permission: List[str]) -> "RoleInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the RoleInstance
|
||||
|
||||
:param permission: A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. Note that the update action replaces all previously assigned permissions with those defined in the update action. To remove a permission, do not include it in the subsequent update action. The values for this parameter depend on the role's `type`.
|
||||
|
||||
:returns: The updated RoleInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
permission=permission,
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.RoleInstance {}>".format(context)
|
||||
|
||||
|
||||
class RoleContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the RoleContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: The SID of the Role resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Roles/{sid}".format(**self._solution)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the RoleInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the RoleInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> RoleInstance:
|
||||
"""
|
||||
Fetch the RoleInstance
|
||||
|
||||
|
||||
:returns: The fetched RoleInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return RoleInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> RoleInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the RoleInstance
|
||||
|
||||
|
||||
:returns: The fetched RoleInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return RoleInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(self, permission: List[str]) -> RoleInstance:
|
||||
"""
|
||||
Update the RoleInstance
|
||||
|
||||
:param permission: A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. Note that the update action replaces all previously assigned permissions with those defined in the update action. To remove a permission, do not include it in the subsequent update action. The values for this parameter depend on the role's `type`.
|
||||
|
||||
:returns: The updated RoleInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Permission": serialize.map(permission, lambda e: e),
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RoleInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
async def update_async(self, permission: List[str]) -> RoleInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the RoleInstance
|
||||
|
||||
:param permission: A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. Note that the update action replaces all previously assigned permissions with those defined in the update action. To remove a permission, do not include it in the subsequent update action. The values for this parameter depend on the role's `type`.
|
||||
|
||||
:returns: The updated RoleInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Permission": serialize.map(permission, lambda e: e),
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RoleInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
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 "<Twilio.Conversations.V1.RoleContext {}>".format(context)
|
||||
|
||||
|
||||
class RolePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> RoleInstance:
|
||||
"""
|
||||
Build an instance of RoleInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return RoleInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.RolePage>"
|
||||
|
||||
|
||||
class RoleList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the RoleList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/Roles"
|
||||
|
||||
def create(
|
||||
self, friendly_name: str, type: "RoleInstance.RoleType", permission: List[str]
|
||||
) -> RoleInstance:
|
||||
"""
|
||||
Create the RoleInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the new resource. It can be up to 64 characters long.
|
||||
:param type:
|
||||
:param permission: A permission that you grant to the new role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. The values for this parameter depend on the role's `type`.
|
||||
|
||||
:returns: The created RoleInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"Type": type,
|
||||
"Permission": serialize.map(permission, lambda e: e),
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RoleInstance(self._version, payload)
|
||||
|
||||
async def create_async(
|
||||
self, friendly_name: str, type: "RoleInstance.RoleType", permission: List[str]
|
||||
) -> RoleInstance:
|
||||
"""
|
||||
Asynchronously create the RoleInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the new resource. It can be up to 64 characters long.
|
||||
:param type:
|
||||
:param permission: A permission that you grant to the new role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. The values for this parameter depend on the role's `type`.
|
||||
|
||||
:returns: The created RoleInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"Type": type,
|
||||
"Permission": serialize.map(permission, lambda e: e),
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RoleInstance(self._version, payload)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[RoleInstance]:
|
||||
"""
|
||||
Streams RoleInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[RoleInstance]:
|
||||
"""
|
||||
Asynchronously streams RoleInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[RoleInstance]:
|
||||
"""
|
||||
Lists RoleInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[RoleInstance]:
|
||||
"""
|
||||
Asynchronously lists RoleInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> RolePage:
|
||||
"""
|
||||
Retrieve a single page of RoleInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of RoleInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return RolePage(self._version, response)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> RolePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of RoleInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of RoleInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return RolePage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> RolePage:
|
||||
"""
|
||||
Retrieve a specific page of RoleInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of RoleInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return RolePage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> RolePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of RoleInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of RoleInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return RolePage(self._version, response)
|
||||
|
||||
def get(self, sid: str) -> RoleContext:
|
||||
"""
|
||||
Constructs a RoleContext
|
||||
|
||||
:param sid: The SID of the Role resource to update.
|
||||
"""
|
||||
return RoleContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> RoleContext:
|
||||
"""
|
||||
Constructs a RoleContext
|
||||
|
||||
:param sid: The SID of the Role resource to update.
|
||||
"""
|
||||
return RoleContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.RoleList>"
|
||||
@@ -0,0 +1,617 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
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.page import Page
|
||||
from twilio.rest.conversations.v1.service.binding import BindingList
|
||||
from twilio.rest.conversations.v1.service.configuration import ConfigurationList
|
||||
from twilio.rest.conversations.v1.service.conversation import ConversationList
|
||||
from twilio.rest.conversations.v1.service.participant_conversation import (
|
||||
ParticipantConversationList,
|
||||
)
|
||||
from twilio.rest.conversations.v1.service.role import RoleList
|
||||
from twilio.rest.conversations.v1.service.user import UserList
|
||||
|
||||
|
||||
class ServiceInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this service.
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar friendly_name: The human-readable name of this service, limited to 256 characters. Optional.
|
||||
:ivar date_created: The date that this resource was created.
|
||||
:ivar date_updated: The date that this resource was last updated.
|
||||
:ivar url: An absolute API resource URL for this service.
|
||||
:ivar links: Contains absolute API resource URLs to access conversations, users, roles, bindings and configuration of this service.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
|
||||
self._solution = {
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[ServiceContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "ServiceContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: ServiceContext for this ServiceInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = ServiceContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ServiceInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ServiceInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "ServiceInstance":
|
||||
"""
|
||||
Fetch the ServiceInstance
|
||||
|
||||
|
||||
:returns: The fetched ServiceInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "ServiceInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ServiceInstance
|
||||
|
||||
|
||||
:returns: The fetched ServiceInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
@property
|
||||
def bindings(self) -> BindingList:
|
||||
"""
|
||||
Access the bindings
|
||||
"""
|
||||
return self._proxy.bindings
|
||||
|
||||
@property
|
||||
def configuration(self) -> ConfigurationList:
|
||||
"""
|
||||
Access the configuration
|
||||
"""
|
||||
return self._proxy.configuration
|
||||
|
||||
@property
|
||||
def conversations(self) -> ConversationList:
|
||||
"""
|
||||
Access the conversations
|
||||
"""
|
||||
return self._proxy.conversations
|
||||
|
||||
@property
|
||||
def participant_conversations(self) -> ParticipantConversationList:
|
||||
"""
|
||||
Access the participant_conversations
|
||||
"""
|
||||
return self._proxy.participant_conversations
|
||||
|
||||
@property
|
||||
def roles(self) -> RoleList:
|
||||
"""
|
||||
Access the roles
|
||||
"""
|
||||
return self._proxy.roles
|
||||
|
||||
@property
|
||||
def users(self) -> UserList:
|
||||
"""
|
||||
Access the users
|
||||
"""
|
||||
return self._proxy.users
|
||||
|
||||
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 "<Twilio.Conversations.V1.ServiceInstance {}>".format(context)
|
||||
|
||||
|
||||
class ServiceContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the ServiceContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Services/{sid}".format(**self._solution)
|
||||
|
||||
self._bindings: Optional[BindingList] = None
|
||||
self._configuration: Optional[ConfigurationList] = None
|
||||
self._conversations: Optional[ConversationList] = None
|
||||
self._participant_conversations: Optional[ParticipantConversationList] = None
|
||||
self._roles: Optional[RoleList] = None
|
||||
self._users: Optional[UserList] = None
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ServiceInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ServiceInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> ServiceInstance:
|
||||
"""
|
||||
Fetch the ServiceInstance
|
||||
|
||||
|
||||
:returns: The fetched ServiceInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ServiceInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> ServiceInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ServiceInstance
|
||||
|
||||
|
||||
:returns: The fetched ServiceInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ServiceInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
@property
|
||||
def bindings(self) -> BindingList:
|
||||
"""
|
||||
Access the bindings
|
||||
"""
|
||||
if self._bindings is None:
|
||||
self._bindings = BindingList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._bindings
|
||||
|
||||
@property
|
||||
def configuration(self) -> ConfigurationList:
|
||||
"""
|
||||
Access the configuration
|
||||
"""
|
||||
if self._configuration is None:
|
||||
self._configuration = ConfigurationList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._configuration
|
||||
|
||||
@property
|
||||
def conversations(self) -> ConversationList:
|
||||
"""
|
||||
Access the conversations
|
||||
"""
|
||||
if self._conversations is None:
|
||||
self._conversations = ConversationList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._conversations
|
||||
|
||||
@property
|
||||
def participant_conversations(self) -> ParticipantConversationList:
|
||||
"""
|
||||
Access the participant_conversations
|
||||
"""
|
||||
if self._participant_conversations is None:
|
||||
self._participant_conversations = ParticipantConversationList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._participant_conversations
|
||||
|
||||
@property
|
||||
def roles(self) -> RoleList:
|
||||
"""
|
||||
Access the roles
|
||||
"""
|
||||
if self._roles is None:
|
||||
self._roles = RoleList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._roles
|
||||
|
||||
@property
|
||||
def users(self) -> UserList:
|
||||
"""
|
||||
Access the users
|
||||
"""
|
||||
if self._users is None:
|
||||
self._users = UserList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._users
|
||||
|
||||
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 "<Twilio.Conversations.V1.ServiceContext {}>".format(context)
|
||||
|
||||
|
||||
class ServicePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> ServiceInstance:
|
||||
"""
|
||||
Build an instance of ServiceInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return ServiceInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.ServicePage>"
|
||||
|
||||
|
||||
class ServiceList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the ServiceList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/Services"
|
||||
|
||||
def create(self, friendly_name: str) -> ServiceInstance:
|
||||
"""
|
||||
Create the ServiceInstance
|
||||
|
||||
:param friendly_name: The human-readable name of this service, limited to 256 characters. Optional.
|
||||
|
||||
:returns: The created ServiceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ServiceInstance(self._version, payload)
|
||||
|
||||
async def create_async(self, friendly_name: str) -> ServiceInstance:
|
||||
"""
|
||||
Asynchronously create the ServiceInstance
|
||||
|
||||
:param friendly_name: The human-readable name of this service, limited to 256 characters. Optional.
|
||||
|
||||
:returns: The created ServiceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ServiceInstance(self._version, payload)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[ServiceInstance]:
|
||||
"""
|
||||
Streams ServiceInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[ServiceInstance]:
|
||||
"""
|
||||
Asynchronously streams ServiceInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ServiceInstance]:
|
||||
"""
|
||||
Lists ServiceInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ServiceInstance]:
|
||||
"""
|
||||
Asynchronously lists ServiceInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ServicePage:
|
||||
"""
|
||||
Retrieve a single page of ServiceInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of ServiceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return ServicePage(self._version, response)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ServicePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of ServiceInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of ServiceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return ServicePage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> ServicePage:
|
||||
"""
|
||||
Retrieve a specific page of ServiceInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ServiceInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return ServicePage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> ServicePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of ServiceInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ServiceInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return ServicePage(self._version, response)
|
||||
|
||||
def get(self, sid: str) -> ServiceContext:
|
||||
"""
|
||||
Constructs a ServiceContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return ServiceContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> ServiceContext:
|
||||
"""
|
||||
Constructs a ServiceContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return ServiceContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.ServiceList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,517 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
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.page import Page
|
||||
|
||||
|
||||
class BindingInstance(InstanceResource):
|
||||
class BindingType(object):
|
||||
APN = "apn"
|
||||
GCM = "gcm"
|
||||
FCM = "fcm"
|
||||
|
||||
"""
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this binding.
|
||||
:ivar chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Binding resource is associated with.
|
||||
:ivar credential_sid: The SID of the [Credential](https://www.twilio.com/docs/conversations/api/credential-resource) for the binding. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info.
|
||||
:ivar date_created: The date that this resource was created.
|
||||
:ivar date_updated: The date that this resource was last updated.
|
||||
:ivar endpoint: The unique endpoint identifier for the Binding. The format of this value depends on the `binding_type`.
|
||||
:ivar identity: The application-defined string that uniquely identifies the [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource) within the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource). See [access tokens](https://www.twilio.com/docs/conversations/create-tokens) for more info.
|
||||
:ivar binding_type:
|
||||
:ivar message_types: The [Conversation message types](https://www.twilio.com/docs/chat/push-notification-configuration#push-types) the binding is subscribed to.
|
||||
:ivar url: An absolute API resource URL for this binding.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
chat_service_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.chat_service_sid: Optional[str] = payload.get("chat_service_sid")
|
||||
self.credential_sid: Optional[str] = payload.get("credential_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.endpoint: Optional[str] = payload.get("endpoint")
|
||||
self.identity: Optional[str] = payload.get("identity")
|
||||
self.binding_type: Optional["BindingInstance.BindingType"] = payload.get(
|
||||
"binding_type"
|
||||
)
|
||||
self.message_types: Optional[List[str]] = payload.get("message_types")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[BindingContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "BindingContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: BindingContext for this BindingInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = BindingContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the BindingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the BindingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "BindingInstance":
|
||||
"""
|
||||
Fetch the BindingInstance
|
||||
|
||||
|
||||
:returns: The fetched BindingInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "BindingInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the BindingInstance
|
||||
|
||||
|
||||
:returns: The fetched BindingInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
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 "<Twilio.Conversations.V1.BindingInstance {}>".format(context)
|
||||
|
||||
|
||||
class BindingContext(InstanceContext):
|
||||
def __init__(self, version: Version, chat_service_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the BindingContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Binding resource is associated with.
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Services/{chat_service_sid}/Bindings/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the BindingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the BindingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> BindingInstance:
|
||||
"""
|
||||
Fetch the BindingInstance
|
||||
|
||||
|
||||
:returns: The fetched BindingInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return BindingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> BindingInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the BindingInstance
|
||||
|
||||
|
||||
:returns: The fetched BindingInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return BindingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.BindingContext {}>".format(context)
|
||||
|
||||
|
||||
class BindingPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> BindingInstance:
|
||||
"""
|
||||
Build an instance of BindingInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return BindingInstance(
|
||||
self._version, payload, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.BindingPage>"
|
||||
|
||||
|
||||
class BindingList(ListResource):
|
||||
def __init__(self, version: Version, chat_service_sid: str):
|
||||
"""
|
||||
Initialize the BindingList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Binding resource is associated with.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
}
|
||||
self._uri = "/Services/{chat_service_sid}/Bindings".format(**self._solution)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
binding_type: Union[List["BindingInstance.BindingType"], object] = values.unset,
|
||||
identity: Union[List[str], object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[BindingInstance]:
|
||||
"""
|
||||
Streams BindingInstance 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 List["BindingInstance.BindingType"] binding_type: The push technology used by the Binding resources to read. Can be: `apn`, `gcm`, or `fcm`. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info.
|
||||
:param List[str] identity: The identity of a [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource) this binding belongs to. See [access tokens](https://www.twilio.com/docs/conversations/create-tokens) for more details.
|
||||
: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(
|
||||
binding_type=binding_type, identity=identity, page_size=limits["page_size"]
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
binding_type: Union[List["BindingInstance.BindingType"], object] = values.unset,
|
||||
identity: Union[List[str], object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[BindingInstance]:
|
||||
"""
|
||||
Asynchronously streams BindingInstance 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 List["BindingInstance.BindingType"] binding_type: The push technology used by the Binding resources to read. Can be: `apn`, `gcm`, or `fcm`. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info.
|
||||
:param List[str] identity: The identity of a [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource) this binding belongs to. See [access tokens](https://www.twilio.com/docs/conversations/create-tokens) for more details.
|
||||
: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(
|
||||
binding_type=binding_type, identity=identity, page_size=limits["page_size"]
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
binding_type: Union[List["BindingInstance.BindingType"], object] = values.unset,
|
||||
identity: Union[List[str], object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[BindingInstance]:
|
||||
"""
|
||||
Lists BindingInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param List["BindingInstance.BindingType"] binding_type: The push technology used by the Binding resources to read. Can be: `apn`, `gcm`, or `fcm`. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info.
|
||||
:param List[str] identity: The identity of a [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource) this binding belongs to. See [access tokens](https://www.twilio.com/docs/conversations/create-tokens) for more details.
|
||||
: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(
|
||||
binding_type=binding_type,
|
||||
identity=identity,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
binding_type: Union[List["BindingInstance.BindingType"], object] = values.unset,
|
||||
identity: Union[List[str], object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[BindingInstance]:
|
||||
"""
|
||||
Asynchronously lists BindingInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param List["BindingInstance.BindingType"] binding_type: The push technology used by the Binding resources to read. Can be: `apn`, `gcm`, or `fcm`. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info.
|
||||
:param List[str] identity: The identity of a [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource) this binding belongs to. See [access tokens](https://www.twilio.com/docs/conversations/create-tokens) for more details.
|
||||
: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(
|
||||
binding_type=binding_type,
|
||||
identity=identity,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
binding_type: Union[List["BindingInstance.BindingType"], object] = values.unset,
|
||||
identity: Union[List[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,
|
||||
) -> BindingPage:
|
||||
"""
|
||||
Retrieve a single page of BindingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param binding_type: The push technology used by the Binding resources to read. Can be: `apn`, `gcm`, or `fcm`. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info.
|
||||
:param identity: The identity of a [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource) this binding belongs to. See [access tokens](https://www.twilio.com/docs/conversations/create-tokens) for more details.
|
||||
: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: Page of BindingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"BindingType": serialize.map(binding_type, lambda e: e),
|
||||
"Identity": serialize.map(identity, lambda e: e),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return BindingPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
binding_type: Union[List["BindingInstance.BindingType"], object] = values.unset,
|
||||
identity: Union[List[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,
|
||||
) -> BindingPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of BindingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param binding_type: The push technology used by the Binding resources to read. Can be: `apn`, `gcm`, or `fcm`. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info.
|
||||
:param identity: The identity of a [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource) this binding belongs to. See [access tokens](https://www.twilio.com/docs/conversations/create-tokens) for more details.
|
||||
: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: Page of BindingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"BindingType": serialize.map(binding_type, lambda e: e),
|
||||
"Identity": serialize.map(identity, lambda e: e),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return BindingPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> BindingPage:
|
||||
"""
|
||||
Retrieve a specific page of BindingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of BindingInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return BindingPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> BindingPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of BindingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of BindingInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return BindingPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> BindingContext:
|
||||
"""
|
||||
Constructs a BindingContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return BindingContext(
|
||||
self._version, chat_service_sid=self._solution["chat_service_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> BindingContext:
|
||||
"""
|
||||
Constructs a BindingContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return BindingContext(
|
||||
self._version, chat_service_sid=self._solution["chat_service_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.BindingList>"
|
||||
+359
@@ -0,0 +1,359 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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, Union
|
||||
from twilio.base import values
|
||||
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.rest.conversations.v1.service.configuration.notification import (
|
||||
NotificationList,
|
||||
)
|
||||
from twilio.rest.conversations.v1.service.configuration.webhook import WebhookList
|
||||
|
||||
|
||||
class ConfigurationInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar chat_service_sid: The unique string that we created to identify the Service configuration resource.
|
||||
:ivar default_conversation_creator_role_sid: The conversation-level role assigned to a conversation creator when they join a new conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles.
|
||||
:ivar default_conversation_role_sid: The conversation-level role assigned to users when they are added to a conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles.
|
||||
:ivar default_chat_service_role_sid: The service-level role assigned to users when they are added to the service. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles.
|
||||
:ivar url: An absolute API resource URL for this service configuration.
|
||||
:ivar links: Contains an absolute API resource URL to access the push notifications configuration of this service.
|
||||
:ivar reachability_enabled: Whether the [Reachability Indicator](https://www.twilio.com/docs/conversations/reachability) is enabled for this Conversations Service. The default is `false`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], chat_service_sid: str
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.chat_service_sid: Optional[str] = payload.get("chat_service_sid")
|
||||
self.default_conversation_creator_role_sid: Optional[str] = payload.get(
|
||||
"default_conversation_creator_role_sid"
|
||||
)
|
||||
self.default_conversation_role_sid: Optional[str] = payload.get(
|
||||
"default_conversation_role_sid"
|
||||
)
|
||||
self.default_chat_service_role_sid: Optional[str] = payload.get(
|
||||
"default_chat_service_role_sid"
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
self.reachability_enabled: Optional[bool] = payload.get("reachability_enabled")
|
||||
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
}
|
||||
self._context: Optional[ConfigurationContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "ConfigurationContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: ConfigurationContext for this ConfigurationInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = ConfigurationContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "ConfigurationInstance":
|
||||
"""
|
||||
Fetch the ConfigurationInstance
|
||||
|
||||
|
||||
:returns: The fetched ConfigurationInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "ConfigurationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ConfigurationInstance
|
||||
|
||||
|
||||
:returns: The fetched ConfigurationInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
default_conversation_creator_role_sid: Union[str, object] = values.unset,
|
||||
default_conversation_role_sid: Union[str, object] = values.unset,
|
||||
default_chat_service_role_sid: Union[str, object] = values.unset,
|
||||
reachability_enabled: Union[bool, object] = values.unset,
|
||||
) -> "ConfigurationInstance":
|
||||
"""
|
||||
Update the ConfigurationInstance
|
||||
|
||||
:param default_conversation_creator_role_sid: The conversation-level role assigned to a conversation creator when they join a new conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles.
|
||||
:param default_conversation_role_sid: The conversation-level role assigned to users when they are added to a conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles.
|
||||
:param default_chat_service_role_sid: The service-level role assigned to users when they are added to the service. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles.
|
||||
:param reachability_enabled: Whether the [Reachability Indicator](https://www.twilio.com/docs/conversations/reachability) is enabled for this Conversations Service. The default is `false`.
|
||||
|
||||
:returns: The updated ConfigurationInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
default_conversation_creator_role_sid=default_conversation_creator_role_sid,
|
||||
default_conversation_role_sid=default_conversation_role_sid,
|
||||
default_chat_service_role_sid=default_chat_service_role_sid,
|
||||
reachability_enabled=reachability_enabled,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
default_conversation_creator_role_sid: Union[str, object] = values.unset,
|
||||
default_conversation_role_sid: Union[str, object] = values.unset,
|
||||
default_chat_service_role_sid: Union[str, object] = values.unset,
|
||||
reachability_enabled: Union[bool, object] = values.unset,
|
||||
) -> "ConfigurationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the ConfigurationInstance
|
||||
|
||||
:param default_conversation_creator_role_sid: The conversation-level role assigned to a conversation creator when they join a new conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles.
|
||||
:param default_conversation_role_sid: The conversation-level role assigned to users when they are added to a conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles.
|
||||
:param default_chat_service_role_sid: The service-level role assigned to users when they are added to the service. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles.
|
||||
:param reachability_enabled: Whether the [Reachability Indicator](https://www.twilio.com/docs/conversations/reachability) is enabled for this Conversations Service. The default is `false`.
|
||||
|
||||
:returns: The updated ConfigurationInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
default_conversation_creator_role_sid=default_conversation_creator_role_sid,
|
||||
default_conversation_role_sid=default_conversation_role_sid,
|
||||
default_chat_service_role_sid=default_chat_service_role_sid,
|
||||
reachability_enabled=reachability_enabled,
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.ConfigurationInstance {}>".format(context)
|
||||
|
||||
|
||||
class ConfigurationContext(InstanceContext):
|
||||
def __init__(self, version: Version, chat_service_sid: str):
|
||||
"""
|
||||
Initialize the ConfigurationContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the Service configuration resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
}
|
||||
self._uri = "/Services/{chat_service_sid}/Configuration".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(self) -> ConfigurationInstance:
|
||||
"""
|
||||
Fetch the ConfigurationInstance
|
||||
|
||||
|
||||
:returns: The fetched ConfigurationInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ConfigurationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> ConfigurationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ConfigurationInstance
|
||||
|
||||
|
||||
:returns: The fetched ConfigurationInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ConfigurationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
default_conversation_creator_role_sid: Union[str, object] = values.unset,
|
||||
default_conversation_role_sid: Union[str, object] = values.unset,
|
||||
default_chat_service_role_sid: Union[str, object] = values.unset,
|
||||
reachability_enabled: Union[bool, object] = values.unset,
|
||||
) -> ConfigurationInstance:
|
||||
"""
|
||||
Update the ConfigurationInstance
|
||||
|
||||
:param default_conversation_creator_role_sid: The conversation-level role assigned to a conversation creator when they join a new conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles.
|
||||
:param default_conversation_role_sid: The conversation-level role assigned to users when they are added to a conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles.
|
||||
:param default_chat_service_role_sid: The service-level role assigned to users when they are added to the service. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles.
|
||||
:param reachability_enabled: Whether the [Reachability Indicator](https://www.twilio.com/docs/conversations/reachability) is enabled for this Conversations Service. The default is `false`.
|
||||
|
||||
:returns: The updated ConfigurationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DefaultConversationCreatorRoleSid": default_conversation_creator_role_sid,
|
||||
"DefaultConversationRoleSid": default_conversation_role_sid,
|
||||
"DefaultChatServiceRoleSid": default_chat_service_role_sid,
|
||||
"ReachabilityEnabled": reachability_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ConfigurationInstance(
|
||||
self._version, payload, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
default_conversation_creator_role_sid: Union[str, object] = values.unset,
|
||||
default_conversation_role_sid: Union[str, object] = values.unset,
|
||||
default_chat_service_role_sid: Union[str, object] = values.unset,
|
||||
reachability_enabled: Union[bool, object] = values.unset,
|
||||
) -> ConfigurationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the ConfigurationInstance
|
||||
|
||||
:param default_conversation_creator_role_sid: The conversation-level role assigned to a conversation creator when they join a new conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles.
|
||||
:param default_conversation_role_sid: The conversation-level role assigned to users when they are added to a conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles.
|
||||
:param default_chat_service_role_sid: The service-level role assigned to users when they are added to the service. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles.
|
||||
:param reachability_enabled: Whether the [Reachability Indicator](https://www.twilio.com/docs/conversations/reachability) is enabled for this Conversations Service. The default is `false`.
|
||||
|
||||
:returns: The updated ConfigurationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DefaultConversationCreatorRoleSid": default_conversation_creator_role_sid,
|
||||
"DefaultConversationRoleSid": default_conversation_role_sid,
|
||||
"DefaultChatServiceRoleSid": default_chat_service_role_sid,
|
||||
"ReachabilityEnabled": reachability_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ConfigurationInstance(
|
||||
self._version, payload, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.ConfigurationContext {}>".format(context)
|
||||
|
||||
|
||||
class ConfigurationList(ListResource):
|
||||
def __init__(self, version: Version, chat_service_sid: str):
|
||||
"""
|
||||
Initialize the ConfigurationList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the Service configuration resource to fetch.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
}
|
||||
|
||||
self._notifications: Optional[NotificationList] = None
|
||||
self._webhooks: Optional[WebhookList] = None
|
||||
|
||||
@property
|
||||
def notifications(self) -> NotificationList:
|
||||
"""
|
||||
Access the notifications
|
||||
"""
|
||||
if self._notifications is None:
|
||||
self._notifications = NotificationList(
|
||||
self._version, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
return self._notifications
|
||||
|
||||
@property
|
||||
def webhooks(self) -> WebhookList:
|
||||
"""
|
||||
Access the webhooks
|
||||
"""
|
||||
if self._webhooks is None:
|
||||
self._webhooks = WebhookList(
|
||||
self._version, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
return self._webhooks
|
||||
|
||||
def get(self) -> ConfigurationContext:
|
||||
"""
|
||||
Constructs a ConfigurationContext
|
||||
|
||||
"""
|
||||
return ConfigurationContext(
|
||||
self._version, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
|
||||
def __call__(self) -> ConfigurationContext:
|
||||
"""
|
||||
Constructs a ConfigurationContext
|
||||
|
||||
"""
|
||||
return ConfigurationContext(
|
||||
self._version, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.ConfigurationList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+435
@@ -0,0 +1,435 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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, Union
|
||||
from twilio.base import values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class NotificationInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this configuration.
|
||||
:ivar chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Configuration applies to.
|
||||
:ivar new_message: The Push Notification configuration for New Messages.
|
||||
:ivar added_to_conversation: The Push Notification configuration for being added to a Conversation.
|
||||
:ivar removed_from_conversation: The Push Notification configuration for being removed from a Conversation.
|
||||
:ivar log_enabled: Weather the notification logging is enabled.
|
||||
:ivar url: An absolute API resource URL for this configuration.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], chat_service_sid: str
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.chat_service_sid: Optional[str] = payload.get("chat_service_sid")
|
||||
self.new_message: Optional[Dict[str, object]] = payload.get("new_message")
|
||||
self.added_to_conversation: Optional[Dict[str, object]] = payload.get(
|
||||
"added_to_conversation"
|
||||
)
|
||||
self.removed_from_conversation: Optional[Dict[str, object]] = payload.get(
|
||||
"removed_from_conversation"
|
||||
)
|
||||
self.log_enabled: Optional[bool] = payload.get("log_enabled")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
}
|
||||
self._context: Optional[NotificationContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "NotificationContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: NotificationContext for this NotificationInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = NotificationContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "NotificationInstance":
|
||||
"""
|
||||
Fetch the NotificationInstance
|
||||
|
||||
|
||||
:returns: The fetched NotificationInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "NotificationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the NotificationInstance
|
||||
|
||||
|
||||
:returns: The fetched NotificationInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
log_enabled: Union[bool, object] = values.unset,
|
||||
new_message_enabled: Union[bool, object] = values.unset,
|
||||
new_message_template: Union[str, object] = values.unset,
|
||||
new_message_sound: Union[str, object] = values.unset,
|
||||
new_message_badge_count_enabled: Union[bool, object] = values.unset,
|
||||
added_to_conversation_enabled: Union[bool, object] = values.unset,
|
||||
added_to_conversation_template: Union[str, object] = values.unset,
|
||||
added_to_conversation_sound: Union[str, object] = values.unset,
|
||||
removed_from_conversation_enabled: Union[bool, object] = values.unset,
|
||||
removed_from_conversation_template: Union[str, object] = values.unset,
|
||||
removed_from_conversation_sound: Union[str, object] = values.unset,
|
||||
new_message_with_media_enabled: Union[bool, object] = values.unset,
|
||||
new_message_with_media_template: Union[str, object] = values.unset,
|
||||
) -> "NotificationInstance":
|
||||
"""
|
||||
Update the NotificationInstance
|
||||
|
||||
:param log_enabled: Weather the notification logging is enabled.
|
||||
:param new_message_enabled: Whether to send a notification when a new message is added to a conversation. The default is `false`.
|
||||
:param new_message_template: The template to use to create the notification text displayed when a new message is added to a conversation and `new_message.enabled` is `true`.
|
||||
:param new_message_sound: The name of the sound to play when a new message is added to a conversation and `new_message.enabled` is `true`.
|
||||
:param new_message_badge_count_enabled: Whether the new message badge is enabled. The default is `false`.
|
||||
:param added_to_conversation_enabled: Whether to send a notification when a participant is added to a conversation. The default is `false`.
|
||||
:param added_to_conversation_template: The template to use to create the notification text displayed when a participant is added to a conversation and `added_to_conversation.enabled` is `true`.
|
||||
:param added_to_conversation_sound: The name of the sound to play when a participant is added to a conversation and `added_to_conversation.enabled` is `true`.
|
||||
:param removed_from_conversation_enabled: Whether to send a notification to a user when they are removed from a conversation. The default is `false`.
|
||||
:param removed_from_conversation_template: The template to use to create the notification text displayed to a user when they are removed from a conversation and `removed_from_conversation.enabled` is `true`.
|
||||
:param removed_from_conversation_sound: The name of the sound to play to a user when they are removed from a conversation and `removed_from_conversation.enabled` is `true`.
|
||||
:param new_message_with_media_enabled: Whether to send a notification when a new message with media/file attachments is added to a conversation. The default is `false`.
|
||||
:param new_message_with_media_template: The template to use to create the notification text displayed when a new message with media/file attachments is added to a conversation and `new_message.attachments.enabled` is `true`.
|
||||
|
||||
:returns: The updated NotificationInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
log_enabled=log_enabled,
|
||||
new_message_enabled=new_message_enabled,
|
||||
new_message_template=new_message_template,
|
||||
new_message_sound=new_message_sound,
|
||||
new_message_badge_count_enabled=new_message_badge_count_enabled,
|
||||
added_to_conversation_enabled=added_to_conversation_enabled,
|
||||
added_to_conversation_template=added_to_conversation_template,
|
||||
added_to_conversation_sound=added_to_conversation_sound,
|
||||
removed_from_conversation_enabled=removed_from_conversation_enabled,
|
||||
removed_from_conversation_template=removed_from_conversation_template,
|
||||
removed_from_conversation_sound=removed_from_conversation_sound,
|
||||
new_message_with_media_enabled=new_message_with_media_enabled,
|
||||
new_message_with_media_template=new_message_with_media_template,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
log_enabled: Union[bool, object] = values.unset,
|
||||
new_message_enabled: Union[bool, object] = values.unset,
|
||||
new_message_template: Union[str, object] = values.unset,
|
||||
new_message_sound: Union[str, object] = values.unset,
|
||||
new_message_badge_count_enabled: Union[bool, object] = values.unset,
|
||||
added_to_conversation_enabled: Union[bool, object] = values.unset,
|
||||
added_to_conversation_template: Union[str, object] = values.unset,
|
||||
added_to_conversation_sound: Union[str, object] = values.unset,
|
||||
removed_from_conversation_enabled: Union[bool, object] = values.unset,
|
||||
removed_from_conversation_template: Union[str, object] = values.unset,
|
||||
removed_from_conversation_sound: Union[str, object] = values.unset,
|
||||
new_message_with_media_enabled: Union[bool, object] = values.unset,
|
||||
new_message_with_media_template: Union[str, object] = values.unset,
|
||||
) -> "NotificationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the NotificationInstance
|
||||
|
||||
:param log_enabled: Weather the notification logging is enabled.
|
||||
:param new_message_enabled: Whether to send a notification when a new message is added to a conversation. The default is `false`.
|
||||
:param new_message_template: The template to use to create the notification text displayed when a new message is added to a conversation and `new_message.enabled` is `true`.
|
||||
:param new_message_sound: The name of the sound to play when a new message is added to a conversation and `new_message.enabled` is `true`.
|
||||
:param new_message_badge_count_enabled: Whether the new message badge is enabled. The default is `false`.
|
||||
:param added_to_conversation_enabled: Whether to send a notification when a participant is added to a conversation. The default is `false`.
|
||||
:param added_to_conversation_template: The template to use to create the notification text displayed when a participant is added to a conversation and `added_to_conversation.enabled` is `true`.
|
||||
:param added_to_conversation_sound: The name of the sound to play when a participant is added to a conversation and `added_to_conversation.enabled` is `true`.
|
||||
:param removed_from_conversation_enabled: Whether to send a notification to a user when they are removed from a conversation. The default is `false`.
|
||||
:param removed_from_conversation_template: The template to use to create the notification text displayed to a user when they are removed from a conversation and `removed_from_conversation.enabled` is `true`.
|
||||
:param removed_from_conversation_sound: The name of the sound to play to a user when they are removed from a conversation and `removed_from_conversation.enabled` is `true`.
|
||||
:param new_message_with_media_enabled: Whether to send a notification when a new message with media/file attachments is added to a conversation. The default is `false`.
|
||||
:param new_message_with_media_template: The template to use to create the notification text displayed when a new message with media/file attachments is added to a conversation and `new_message.attachments.enabled` is `true`.
|
||||
|
||||
:returns: The updated NotificationInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
log_enabled=log_enabled,
|
||||
new_message_enabled=new_message_enabled,
|
||||
new_message_template=new_message_template,
|
||||
new_message_sound=new_message_sound,
|
||||
new_message_badge_count_enabled=new_message_badge_count_enabled,
|
||||
added_to_conversation_enabled=added_to_conversation_enabled,
|
||||
added_to_conversation_template=added_to_conversation_template,
|
||||
added_to_conversation_sound=added_to_conversation_sound,
|
||||
removed_from_conversation_enabled=removed_from_conversation_enabled,
|
||||
removed_from_conversation_template=removed_from_conversation_template,
|
||||
removed_from_conversation_sound=removed_from_conversation_sound,
|
||||
new_message_with_media_enabled=new_message_with_media_enabled,
|
||||
new_message_with_media_template=new_message_with_media_template,
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.NotificationInstance {}>".format(context)
|
||||
|
||||
|
||||
class NotificationContext(InstanceContext):
|
||||
def __init__(self, version: Version, chat_service_sid: str):
|
||||
"""
|
||||
Initialize the NotificationContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Configuration applies to.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
}
|
||||
self._uri = "/Services/{chat_service_sid}/Configuration/Notifications".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(self) -> NotificationInstance:
|
||||
"""
|
||||
Fetch the NotificationInstance
|
||||
|
||||
|
||||
:returns: The fetched NotificationInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return NotificationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> NotificationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the NotificationInstance
|
||||
|
||||
|
||||
:returns: The fetched NotificationInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return NotificationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
log_enabled: Union[bool, object] = values.unset,
|
||||
new_message_enabled: Union[bool, object] = values.unset,
|
||||
new_message_template: Union[str, object] = values.unset,
|
||||
new_message_sound: Union[str, object] = values.unset,
|
||||
new_message_badge_count_enabled: Union[bool, object] = values.unset,
|
||||
added_to_conversation_enabled: Union[bool, object] = values.unset,
|
||||
added_to_conversation_template: Union[str, object] = values.unset,
|
||||
added_to_conversation_sound: Union[str, object] = values.unset,
|
||||
removed_from_conversation_enabled: Union[bool, object] = values.unset,
|
||||
removed_from_conversation_template: Union[str, object] = values.unset,
|
||||
removed_from_conversation_sound: Union[str, object] = values.unset,
|
||||
new_message_with_media_enabled: Union[bool, object] = values.unset,
|
||||
new_message_with_media_template: Union[str, object] = values.unset,
|
||||
) -> NotificationInstance:
|
||||
"""
|
||||
Update the NotificationInstance
|
||||
|
||||
:param log_enabled: Weather the notification logging is enabled.
|
||||
:param new_message_enabled: Whether to send a notification when a new message is added to a conversation. The default is `false`.
|
||||
:param new_message_template: The template to use to create the notification text displayed when a new message is added to a conversation and `new_message.enabled` is `true`.
|
||||
:param new_message_sound: The name of the sound to play when a new message is added to a conversation and `new_message.enabled` is `true`.
|
||||
:param new_message_badge_count_enabled: Whether the new message badge is enabled. The default is `false`.
|
||||
:param added_to_conversation_enabled: Whether to send a notification when a participant is added to a conversation. The default is `false`.
|
||||
:param added_to_conversation_template: The template to use to create the notification text displayed when a participant is added to a conversation and `added_to_conversation.enabled` is `true`.
|
||||
:param added_to_conversation_sound: The name of the sound to play when a participant is added to a conversation and `added_to_conversation.enabled` is `true`.
|
||||
:param removed_from_conversation_enabled: Whether to send a notification to a user when they are removed from a conversation. The default is `false`.
|
||||
:param removed_from_conversation_template: The template to use to create the notification text displayed to a user when they are removed from a conversation and `removed_from_conversation.enabled` is `true`.
|
||||
:param removed_from_conversation_sound: The name of the sound to play to a user when they are removed from a conversation and `removed_from_conversation.enabled` is `true`.
|
||||
:param new_message_with_media_enabled: Whether to send a notification when a new message with media/file attachments is added to a conversation. The default is `false`.
|
||||
:param new_message_with_media_template: The template to use to create the notification text displayed when a new message with media/file attachments is added to a conversation and `new_message.attachments.enabled` is `true`.
|
||||
|
||||
:returns: The updated NotificationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"LogEnabled": log_enabled,
|
||||
"NewMessage.Enabled": new_message_enabled,
|
||||
"NewMessage.Template": new_message_template,
|
||||
"NewMessage.Sound": new_message_sound,
|
||||
"NewMessage.BadgeCountEnabled": new_message_badge_count_enabled,
|
||||
"AddedToConversation.Enabled": added_to_conversation_enabled,
|
||||
"AddedToConversation.Template": added_to_conversation_template,
|
||||
"AddedToConversation.Sound": added_to_conversation_sound,
|
||||
"RemovedFromConversation.Enabled": removed_from_conversation_enabled,
|
||||
"RemovedFromConversation.Template": removed_from_conversation_template,
|
||||
"RemovedFromConversation.Sound": removed_from_conversation_sound,
|
||||
"NewMessage.WithMedia.Enabled": new_message_with_media_enabled,
|
||||
"NewMessage.WithMedia.Template": new_message_with_media_template,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return NotificationInstance(
|
||||
self._version, payload, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
log_enabled: Union[bool, object] = values.unset,
|
||||
new_message_enabled: Union[bool, object] = values.unset,
|
||||
new_message_template: Union[str, object] = values.unset,
|
||||
new_message_sound: Union[str, object] = values.unset,
|
||||
new_message_badge_count_enabled: Union[bool, object] = values.unset,
|
||||
added_to_conversation_enabled: Union[bool, object] = values.unset,
|
||||
added_to_conversation_template: Union[str, object] = values.unset,
|
||||
added_to_conversation_sound: Union[str, object] = values.unset,
|
||||
removed_from_conversation_enabled: Union[bool, object] = values.unset,
|
||||
removed_from_conversation_template: Union[str, object] = values.unset,
|
||||
removed_from_conversation_sound: Union[str, object] = values.unset,
|
||||
new_message_with_media_enabled: Union[bool, object] = values.unset,
|
||||
new_message_with_media_template: Union[str, object] = values.unset,
|
||||
) -> NotificationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the NotificationInstance
|
||||
|
||||
:param log_enabled: Weather the notification logging is enabled.
|
||||
:param new_message_enabled: Whether to send a notification when a new message is added to a conversation. The default is `false`.
|
||||
:param new_message_template: The template to use to create the notification text displayed when a new message is added to a conversation and `new_message.enabled` is `true`.
|
||||
:param new_message_sound: The name of the sound to play when a new message is added to a conversation and `new_message.enabled` is `true`.
|
||||
:param new_message_badge_count_enabled: Whether the new message badge is enabled. The default is `false`.
|
||||
:param added_to_conversation_enabled: Whether to send a notification when a participant is added to a conversation. The default is `false`.
|
||||
:param added_to_conversation_template: The template to use to create the notification text displayed when a participant is added to a conversation and `added_to_conversation.enabled` is `true`.
|
||||
:param added_to_conversation_sound: The name of the sound to play when a participant is added to a conversation and `added_to_conversation.enabled` is `true`.
|
||||
:param removed_from_conversation_enabled: Whether to send a notification to a user when they are removed from a conversation. The default is `false`.
|
||||
:param removed_from_conversation_template: The template to use to create the notification text displayed to a user when they are removed from a conversation and `removed_from_conversation.enabled` is `true`.
|
||||
:param removed_from_conversation_sound: The name of the sound to play to a user when they are removed from a conversation and `removed_from_conversation.enabled` is `true`.
|
||||
:param new_message_with_media_enabled: Whether to send a notification when a new message with media/file attachments is added to a conversation. The default is `false`.
|
||||
:param new_message_with_media_template: The template to use to create the notification text displayed when a new message with media/file attachments is added to a conversation and `new_message.attachments.enabled` is `true`.
|
||||
|
||||
:returns: The updated NotificationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"LogEnabled": log_enabled,
|
||||
"NewMessage.Enabled": new_message_enabled,
|
||||
"NewMessage.Template": new_message_template,
|
||||
"NewMessage.Sound": new_message_sound,
|
||||
"NewMessage.BadgeCountEnabled": new_message_badge_count_enabled,
|
||||
"AddedToConversation.Enabled": added_to_conversation_enabled,
|
||||
"AddedToConversation.Template": added_to_conversation_template,
|
||||
"AddedToConversation.Sound": added_to_conversation_sound,
|
||||
"RemovedFromConversation.Enabled": removed_from_conversation_enabled,
|
||||
"RemovedFromConversation.Template": removed_from_conversation_template,
|
||||
"RemovedFromConversation.Sound": removed_from_conversation_sound,
|
||||
"NewMessage.WithMedia.Enabled": new_message_with_media_enabled,
|
||||
"NewMessage.WithMedia.Template": new_message_with_media_template,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return NotificationInstance(
|
||||
self._version, payload, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.NotificationContext {}>".format(context)
|
||||
|
||||
|
||||
class NotificationList(ListResource):
|
||||
def __init__(self, version: Version, chat_service_sid: str):
|
||||
"""
|
||||
Initialize the NotificationList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Configuration applies to.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
}
|
||||
|
||||
def get(self) -> NotificationContext:
|
||||
"""
|
||||
Constructs a NotificationContext
|
||||
|
||||
"""
|
||||
return NotificationContext(
|
||||
self._version, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
|
||||
def __call__(self) -> NotificationContext:
|
||||
"""
|
||||
Constructs a NotificationContext
|
||||
|
||||
"""
|
||||
return NotificationContext(
|
||||
self._version, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.NotificationList>"
|
||||
+326
@@ -0,0 +1,326 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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, Union
|
||||
from twilio.base import serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class WebhookInstance(InstanceResource):
|
||||
class Method(object):
|
||||
GET = "GET"
|
||||
POST = "POST"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this service.
|
||||
:ivar chat_service_sid: The unique ID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation belongs to.
|
||||
:ivar pre_webhook_url: The absolute url the pre-event webhook request should be sent to.
|
||||
:ivar post_webhook_url: The absolute url the post-event webhook request should be sent to.
|
||||
:ivar filters: The list of events that your configured webhook targets will receive. Events not configured here will not fire. Possible values are `onParticipantAdd`, `onParticipantAdded`, `onDeliveryUpdated`, `onConversationUpdated`, `onConversationRemove`, `onParticipantRemove`, `onConversationUpdate`, `onMessageAdd`, `onMessageRemoved`, `onParticipantUpdated`, `onConversationAdded`, `onMessageAdded`, `onConversationAdd`, `onConversationRemoved`, `onParticipantUpdate`, `onMessageRemove`, `onMessageUpdated`, `onParticipantRemoved`, `onMessageUpdate` or `onConversationStateUpdated`.
|
||||
:ivar method:
|
||||
:ivar url: An absolute API resource URL for this webhook.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], chat_service_sid: str
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.chat_service_sid: Optional[str] = payload.get("chat_service_sid")
|
||||
self.pre_webhook_url: Optional[str] = payload.get("pre_webhook_url")
|
||||
self.post_webhook_url: Optional[str] = payload.get("post_webhook_url")
|
||||
self.filters: Optional[List[str]] = payload.get("filters")
|
||||
self.method: Optional["WebhookInstance.Method"] = payload.get("method")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
}
|
||||
self._context: Optional[WebhookContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "WebhookContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: WebhookContext for this WebhookInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = WebhookContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "WebhookInstance":
|
||||
"""
|
||||
Fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "WebhookInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
pre_webhook_url: Union[str, object] = values.unset,
|
||||
post_webhook_url: Union[str, object] = values.unset,
|
||||
filters: Union[List[str], object] = values.unset,
|
||||
method: Union[str, object] = values.unset,
|
||||
) -> "WebhookInstance":
|
||||
"""
|
||||
Update the WebhookInstance
|
||||
|
||||
:param pre_webhook_url: The absolute url the pre-event webhook request should be sent to.
|
||||
:param post_webhook_url: The absolute url the post-event webhook request should be sent to.
|
||||
:param filters: The list of events that your configured webhook targets will receive. Events not configured here will not fire. Possible values are `onParticipantAdd`, `onParticipantAdded`, `onDeliveryUpdated`, `onConversationUpdated`, `onConversationRemove`, `onParticipantRemove`, `onConversationUpdate`, `onMessageAdd`, `onMessageRemoved`, `onParticipantUpdated`, `onConversationAdded`, `onMessageAdded`, `onConversationAdd`, `onConversationRemoved`, `onParticipantUpdate`, `onMessageRemove`, `onMessageUpdated`, `onParticipantRemoved`, `onMessageUpdate` or `onConversationStateUpdated`.
|
||||
:param method: The HTTP method to be used when sending a webhook request. One of `GET` or `POST`.
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
pre_webhook_url=pre_webhook_url,
|
||||
post_webhook_url=post_webhook_url,
|
||||
filters=filters,
|
||||
method=method,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
pre_webhook_url: Union[str, object] = values.unset,
|
||||
post_webhook_url: Union[str, object] = values.unset,
|
||||
filters: Union[List[str], object] = values.unset,
|
||||
method: Union[str, object] = values.unset,
|
||||
) -> "WebhookInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the WebhookInstance
|
||||
|
||||
:param pre_webhook_url: The absolute url the pre-event webhook request should be sent to.
|
||||
:param post_webhook_url: The absolute url the post-event webhook request should be sent to.
|
||||
:param filters: The list of events that your configured webhook targets will receive. Events not configured here will not fire. Possible values are `onParticipantAdd`, `onParticipantAdded`, `onDeliveryUpdated`, `onConversationUpdated`, `onConversationRemove`, `onParticipantRemove`, `onConversationUpdate`, `onMessageAdd`, `onMessageRemoved`, `onParticipantUpdated`, `onConversationAdded`, `onMessageAdded`, `onConversationAdd`, `onConversationRemoved`, `onParticipantUpdate`, `onMessageRemove`, `onMessageUpdated`, `onParticipantRemoved`, `onMessageUpdate` or `onConversationStateUpdated`.
|
||||
:param method: The HTTP method to be used when sending a webhook request. One of `GET` or `POST`.
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
pre_webhook_url=pre_webhook_url,
|
||||
post_webhook_url=post_webhook_url,
|
||||
filters=filters,
|
||||
method=method,
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.WebhookInstance {}>".format(context)
|
||||
|
||||
|
||||
class WebhookContext(InstanceContext):
|
||||
def __init__(self, version: Version, chat_service_sid: str):
|
||||
"""
|
||||
Initialize the WebhookContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The unique ID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation belongs to.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
}
|
||||
self._uri = "/Services/{chat_service_sid}/Configuration/Webhooks".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(self) -> WebhookInstance:
|
||||
"""
|
||||
Fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> WebhookInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
pre_webhook_url: Union[str, object] = values.unset,
|
||||
post_webhook_url: Union[str, object] = values.unset,
|
||||
filters: Union[List[str], object] = values.unset,
|
||||
method: Union[str, object] = values.unset,
|
||||
) -> WebhookInstance:
|
||||
"""
|
||||
Update the WebhookInstance
|
||||
|
||||
:param pre_webhook_url: The absolute url the pre-event webhook request should be sent to.
|
||||
:param post_webhook_url: The absolute url the post-event webhook request should be sent to.
|
||||
:param filters: The list of events that your configured webhook targets will receive. Events not configured here will not fire. Possible values are `onParticipantAdd`, `onParticipantAdded`, `onDeliveryUpdated`, `onConversationUpdated`, `onConversationRemove`, `onParticipantRemove`, `onConversationUpdate`, `onMessageAdd`, `onMessageRemoved`, `onParticipantUpdated`, `onConversationAdded`, `onMessageAdded`, `onConversationAdd`, `onConversationRemoved`, `onParticipantUpdate`, `onMessageRemove`, `onMessageUpdated`, `onParticipantRemoved`, `onMessageUpdate` or `onConversationStateUpdated`.
|
||||
:param method: The HTTP method to be used when sending a webhook request. One of `GET` or `POST`.
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PreWebhookUrl": pre_webhook_url,
|
||||
"PostWebhookUrl": post_webhook_url,
|
||||
"Filters": serialize.map(filters, lambda e: e),
|
||||
"Method": method,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version, payload, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
pre_webhook_url: Union[str, object] = values.unset,
|
||||
post_webhook_url: Union[str, object] = values.unset,
|
||||
filters: Union[List[str], object] = values.unset,
|
||||
method: Union[str, object] = values.unset,
|
||||
) -> WebhookInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the WebhookInstance
|
||||
|
||||
:param pre_webhook_url: The absolute url the pre-event webhook request should be sent to.
|
||||
:param post_webhook_url: The absolute url the post-event webhook request should be sent to.
|
||||
:param filters: The list of events that your configured webhook targets will receive. Events not configured here will not fire. Possible values are `onParticipantAdd`, `onParticipantAdded`, `onDeliveryUpdated`, `onConversationUpdated`, `onConversationRemove`, `onParticipantRemove`, `onConversationUpdate`, `onMessageAdd`, `onMessageRemoved`, `onParticipantUpdated`, `onConversationAdded`, `onMessageAdded`, `onConversationAdd`, `onConversationRemoved`, `onParticipantUpdate`, `onMessageRemove`, `onMessageUpdated`, `onParticipantRemoved`, `onMessageUpdate` or `onConversationStateUpdated`.
|
||||
:param method: The HTTP method to be used when sending a webhook request. One of `GET` or `POST`.
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PreWebhookUrl": pre_webhook_url,
|
||||
"PostWebhookUrl": post_webhook_url,
|
||||
"Filters": serialize.map(filters, lambda e: e),
|
||||
"Method": method,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version, payload, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.WebhookContext {}>".format(context)
|
||||
|
||||
|
||||
class WebhookList(ListResource):
|
||||
def __init__(self, version: Version, chat_service_sid: str):
|
||||
"""
|
||||
Initialize the WebhookList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The unique ID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation belongs to.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
}
|
||||
|
||||
def get(self) -> WebhookContext:
|
||||
"""
|
||||
Constructs a WebhookContext
|
||||
|
||||
"""
|
||||
return WebhookContext(
|
||||
self._version, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
|
||||
def __call__(self) -> WebhookContext:
|
||||
"""
|
||||
Constructs a WebhookContext
|
||||
|
||||
"""
|
||||
return WebhookContext(
|
||||
self._version, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.WebhookList>"
|
||||
+1014
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+888
@@ -0,0 +1,888 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
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.page import Page
|
||||
from twilio.rest.conversations.v1.service.conversation.message.delivery_receipt import (
|
||||
DeliveryReceiptList,
|
||||
)
|
||||
|
||||
|
||||
class MessageInstance(InstanceResource):
|
||||
class OrderType(object):
|
||||
ASC = "asc"
|
||||
DESC = "desc"
|
||||
|
||||
class WebhookEnabledType(object):
|
||||
TRUE = "true"
|
||||
FALSE = "false"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this message.
|
||||
:ivar chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Participant resource is associated with.
|
||||
:ivar conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this message.
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar index: The index of the message within the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource).
|
||||
:ivar author: The channel specific identifier of the message's author. Defaults to `system`.
|
||||
:ivar body: The content of the message, can be up to 1,600 characters long.
|
||||
:ivar media: An array of objects that describe the Message's media, if the message contains media. Each object contains these fields: `content_type` with the MIME type of the media, `filename` with the name of the media, `sid` with the SID of the Media resource, and `size` with the media object's file size in bytes. If the Message has no media, this value is `null`.
|
||||
:ivar attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \"{}\" will be returned.
|
||||
:ivar participant_sid: The unique ID of messages's author participant. Null in case of `system` sent message.
|
||||
:ivar date_created: The date that this resource was created.
|
||||
:ivar date_updated: The date that this resource was last updated. `null` if the message has not been edited.
|
||||
:ivar delivery: An object that contains the summary of delivery statuses for the message to non-chat participants.
|
||||
:ivar url: An absolute API resource URL for this message.
|
||||
:ivar links: Contains an absolute API resource URL to access the delivery & read receipts of this message.
|
||||
:ivar content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content-api) template.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
chat_service_sid: str,
|
||||
conversation_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.chat_service_sid: Optional[str] = payload.get("chat_service_sid")
|
||||
self.conversation_sid: Optional[str] = payload.get("conversation_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
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[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(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.delivery: Optional[Dict[str, object]] = payload.get("delivery")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
self.content_sid: Optional[str] = payload.get("content_sid")
|
||||
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"conversation_sid": conversation_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[MessageContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "MessageContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: MessageContext for this MessageInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = MessageContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"MessageInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Deletes the MessageInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
)
|
||||
|
||||
async def delete_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"MessageInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the MessageInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
)
|
||||
|
||||
def fetch(self) -> "MessageInstance":
|
||||
"""
|
||||
Fetch the MessageInstance
|
||||
|
||||
|
||||
:returns: The fetched MessageInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "MessageInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the MessageInstance
|
||||
|
||||
|
||||
:returns: The fetched MessageInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"MessageInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
author: Union[str, object] = values.unset,
|
||||
body: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
subject: Union[str, object] = values.unset,
|
||||
) -> "MessageInstance":
|
||||
"""
|
||||
Update the MessageInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param author: The channel specific identifier of the message's author. Defaults to `system`.
|
||||
:param body: The content of the message, can be up to 1,600 characters long.
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated. `null` if the message has not been edited.
|
||||
:param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param subject: The subject of the message, can be up to 256 characters long.
|
||||
|
||||
:returns: The updated MessageInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
author=author,
|
||||
body=body,
|
||||
date_created=date_created,
|
||||
date_updated=date_updated,
|
||||
attributes=attributes,
|
||||
subject=subject,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"MessageInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
author: Union[str, object] = values.unset,
|
||||
body: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
subject: Union[str, object] = values.unset,
|
||||
) -> "MessageInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the MessageInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param author: The channel specific identifier of the message's author. Defaults to `system`.
|
||||
:param body: The content of the message, can be up to 1,600 characters long.
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated. `null` if the message has not been edited.
|
||||
:param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param subject: The subject of the message, can be up to 256 characters long.
|
||||
|
||||
:returns: The updated MessageInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
author=author,
|
||||
body=body,
|
||||
date_created=date_created,
|
||||
date_updated=date_updated,
|
||||
attributes=attributes,
|
||||
subject=subject,
|
||||
)
|
||||
|
||||
@property
|
||||
def delivery_receipts(self) -> DeliveryReceiptList:
|
||||
"""
|
||||
Access the delivery_receipts
|
||||
"""
|
||||
return self._proxy.delivery_receipts
|
||||
|
||||
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 "<Twilio.Conversations.V1.MessageInstance {}>".format(context)
|
||||
|
||||
|
||||
class MessageContext(InstanceContext):
|
||||
def __init__(
|
||||
self, version: Version, chat_service_sid: str, conversation_sid: str, sid: str
|
||||
):
|
||||
"""
|
||||
Initialize the MessageContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Participant resource is associated with.
|
||||
:param conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this message.
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"conversation_sid": conversation_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Services/{chat_service_sid}/Conversations/{conversation_sid}/Messages/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
self._delivery_receipts: Optional[DeliveryReceiptList] = None
|
||||
|
||||
def delete(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"MessageInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Deletes the MessageInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
return self._version.delete(method="DELETE", uri=self._uri, headers=headers)
|
||||
|
||||
async def delete_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"MessageInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the MessageInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
return await self._version.delete_async(
|
||||
method="DELETE", uri=self._uri, headers=headers
|
||||
)
|
||||
|
||||
def fetch(self) -> MessageInstance:
|
||||
"""
|
||||
Fetch the MessageInstance
|
||||
|
||||
|
||||
:returns: The fetched MessageInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return MessageInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> MessageInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the MessageInstance
|
||||
|
||||
|
||||
:returns: The fetched MessageInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return MessageInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"MessageInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
author: Union[str, object] = values.unset,
|
||||
body: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
subject: Union[str, object] = values.unset,
|
||||
) -> MessageInstance:
|
||||
"""
|
||||
Update the MessageInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param author: The channel specific identifier of the message's author. Defaults to `system`.
|
||||
:param body: The content of the message, can be up to 1,600 characters long.
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated. `null` if the message has not been edited.
|
||||
:param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param subject: The subject of the message, can be up to 256 characters long.
|
||||
|
||||
:returns: The updated MessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Author": author,
|
||||
"Body": body,
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateUpdated": serialize.iso8601_datetime(date_updated),
|
||||
"Attributes": attributes,
|
||||
"Subject": subject,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return MessageInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"MessageInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
author: Union[str, object] = values.unset,
|
||||
body: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
subject: Union[str, object] = values.unset,
|
||||
) -> MessageInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the MessageInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param author: The channel specific identifier of the message's author. Defaults to `system`.
|
||||
:param body: The content of the message, can be up to 1,600 characters long.
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated. `null` if the message has not been edited.
|
||||
:param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param subject: The subject of the message, can be up to 256 characters long.
|
||||
|
||||
:returns: The updated MessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Author": author,
|
||||
"Body": body,
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateUpdated": serialize.iso8601_datetime(date_updated),
|
||||
"Attributes": attributes,
|
||||
"Subject": subject,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return MessageInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
@property
|
||||
def delivery_receipts(self) -> DeliveryReceiptList:
|
||||
"""
|
||||
Access the delivery_receipts
|
||||
"""
|
||||
if self._delivery_receipts is None:
|
||||
self._delivery_receipts = DeliveryReceiptList(
|
||||
self._version,
|
||||
self._solution["chat_service_sid"],
|
||||
self._solution["conversation_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._delivery_receipts
|
||||
|
||||
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 "<Twilio.Conversations.V1.MessageContext {}>".format(context)
|
||||
|
||||
|
||||
class MessagePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> MessageInstance:
|
||||
"""
|
||||
Build an instance of MessageInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return MessageInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.MessagePage>"
|
||||
|
||||
|
||||
class MessageList(ListResource):
|
||||
def __init__(self, version: Version, chat_service_sid: str, conversation_sid: str):
|
||||
"""
|
||||
Initialize the MessageList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Participant resource is associated with.
|
||||
:param conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for messages.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"conversation_sid": conversation_sid,
|
||||
}
|
||||
self._uri = "/Services/{chat_service_sid}/Conversations/{conversation_sid}/Messages".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"MessageInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
author: Union[str, object] = values.unset,
|
||||
body: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
media_sid: Union[str, object] = values.unset,
|
||||
content_sid: Union[str, object] = values.unset,
|
||||
content_variables: Union[str, object] = values.unset,
|
||||
subject: Union[str, object] = values.unset,
|
||||
) -> MessageInstance:
|
||||
"""
|
||||
Create the MessageInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param author: The channel specific identifier of the message's author. Defaults to `system`.
|
||||
:param body: The content of the message, can be up to 1,600 characters long.
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated. `null` if the message has not been edited.
|
||||
:param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param media_sid: The Media SID to be attached to the new Message.
|
||||
:param content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content-api) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored.
|
||||
:param content_variables: A structurally valid JSON string that contains values to resolve Rich Content template variables.
|
||||
:param subject: The subject of the message, can be up to 256 characters long.
|
||||
|
||||
:returns: The created MessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Author": author,
|
||||
"Body": body,
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateUpdated": serialize.iso8601_datetime(date_updated),
|
||||
"Attributes": attributes,
|
||||
"MediaSid": media_sid,
|
||||
"ContentSid": content_sid,
|
||||
"ContentVariables": content_variables,
|
||||
"Subject": subject,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
payload = self._version.create(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return MessageInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"MessageInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
author: Union[str, object] = values.unset,
|
||||
body: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
media_sid: Union[str, object] = values.unset,
|
||||
content_sid: Union[str, object] = values.unset,
|
||||
content_variables: Union[str, object] = values.unset,
|
||||
subject: Union[str, object] = values.unset,
|
||||
) -> MessageInstance:
|
||||
"""
|
||||
Asynchronously create the MessageInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param author: The channel specific identifier of the message's author. Defaults to `system`.
|
||||
:param body: The content of the message, can be up to 1,600 characters long.
|
||||
:param date_created: The date that this resource was created.
|
||||
:param date_updated: The date that this resource was last updated. `null` if the message has not been edited.
|
||||
:param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned.
|
||||
:param media_sid: The Media SID to be attached to the new Message.
|
||||
:param content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content-api) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored.
|
||||
:param content_variables: A structurally valid JSON string that contains values to resolve Rich Content template variables.
|
||||
:param subject: The subject of the message, can be up to 256 characters long.
|
||||
|
||||
:returns: The created MessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Author": author,
|
||||
"Body": body,
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateUpdated": serialize.iso8601_datetime(date_updated),
|
||||
"Attributes": attributes,
|
||||
"MediaSid": media_sid,
|
||||
"ContentSid": content_sid,
|
||||
"ContentVariables": content_variables,
|
||||
"Subject": subject,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
payload = await self._version.create_async(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return MessageInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
order: Union["MessageInstance.OrderType", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[MessageInstance]:
|
||||
"""
|
||||
Streams MessageInstance 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 "MessageInstance.OrderType" order: The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending), with `asc` as the default.
|
||||
: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(order=order, page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
order: Union["MessageInstance.OrderType", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[MessageInstance]:
|
||||
"""
|
||||
Asynchronously streams MessageInstance 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 "MessageInstance.OrderType" order: The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending), with `asc` as the default.
|
||||
: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(order=order, page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
order: Union["MessageInstance.OrderType", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MessageInstance]:
|
||||
"""
|
||||
Lists MessageInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param "MessageInstance.OrderType" order: The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending), with `asc` as the default.
|
||||
: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(
|
||||
order=order,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
order: Union["MessageInstance.OrderType", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MessageInstance]:
|
||||
"""
|
||||
Asynchronously lists MessageInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param "MessageInstance.OrderType" order: The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending), with `asc` as the default.
|
||||
: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(
|
||||
order=order,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
order: Union["MessageInstance.OrderType", object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MessagePage:
|
||||
"""
|
||||
Retrieve a single page of MessageInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param order: The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending), with `asc` as the default.
|
||||
: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: Page of MessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Order": order,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return MessagePage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
order: Union["MessageInstance.OrderType", object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MessagePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of MessageInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param order: The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending), with `asc` as the default.
|
||||
: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: Page of MessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Order": order,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return MessagePage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> MessagePage:
|
||||
"""
|
||||
Retrieve a specific page of MessageInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MessageInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return MessagePage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> MessagePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of MessageInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MessageInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return MessagePage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> MessageContext:
|
||||
"""
|
||||
Constructs a MessageContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return MessageContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> MessageContext:
|
||||
"""
|
||||
Constructs a MessageContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return MessageContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.MessageList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+488
@@ -0,0 +1,488 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
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.page import Page
|
||||
|
||||
|
||||
class DeliveryReceiptInstance(InstanceResource):
|
||||
class DeliveryStatus(object):
|
||||
READ = "read"
|
||||
FAILED = "failed"
|
||||
DELIVERED = "delivered"
|
||||
UNDELIVERED = "undelivered"
|
||||
SENT = "sent"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this participant.
|
||||
:ivar chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Message resource is associated with.
|
||||
:ivar conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this message.
|
||||
:ivar message_sid: The SID of the message within a [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) the delivery receipt belongs to
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar channel_message_sid: A messaging channel-specific identifier for the message delivered to participant e.g. `SMxx` for SMS, `WAxx` for Whatsapp etc.
|
||||
:ivar participant_sid: The unique ID of the participant the delivery receipt belongs to.
|
||||
:ivar status:
|
||||
:ivar error_code: The message [delivery error code](https://www.twilio.com/docs/sms/api/message-resource#delivery-related-errors) for a `failed` status,
|
||||
:ivar date_created: The date that this resource was created.
|
||||
:ivar date_updated: The date that this resource was last updated. `null` if the delivery receipt has not been updated.
|
||||
:ivar url: An absolute API resource URL for this delivery receipt.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
chat_service_sid: str,
|
||||
conversation_sid: str,
|
||||
message_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.chat_service_sid: Optional[str] = payload.get("chat_service_sid")
|
||||
self.conversation_sid: Optional[str] = payload.get("conversation_sid")
|
||||
self.message_sid: Optional[str] = payload.get("message_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.channel_message_sid: Optional[str] = payload.get("channel_message_sid")
|
||||
self.participant_sid: Optional[str] = payload.get("participant_sid")
|
||||
self.status: Optional["DeliveryReceiptInstance.DeliveryStatus"] = payload.get(
|
||||
"status"
|
||||
)
|
||||
self.error_code: Optional[int] = deserialize.integer(payload.get("error_code"))
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"conversation_sid": conversation_sid,
|
||||
"message_sid": message_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[DeliveryReceiptContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "DeliveryReceiptContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: DeliveryReceiptContext for this DeliveryReceiptInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = DeliveryReceiptContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
message_sid=self._solution["message_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "DeliveryReceiptInstance":
|
||||
"""
|
||||
Fetch the DeliveryReceiptInstance
|
||||
|
||||
|
||||
:returns: The fetched DeliveryReceiptInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "DeliveryReceiptInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the DeliveryReceiptInstance
|
||||
|
||||
|
||||
:returns: The fetched DeliveryReceiptInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
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 "<Twilio.Conversations.V1.DeliveryReceiptInstance {}>".format(context)
|
||||
|
||||
|
||||
class DeliveryReceiptContext(InstanceContext):
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
chat_service_sid: str,
|
||||
conversation_sid: str,
|
||||
message_sid: str,
|
||||
sid: str,
|
||||
):
|
||||
"""
|
||||
Initialize the DeliveryReceiptContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Message resource is associated with.
|
||||
:param conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this message.
|
||||
:param message_sid: The SID of the message within a [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) the delivery receipt belongs to.
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"conversation_sid": conversation_sid,
|
||||
"message_sid": message_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Services/{chat_service_sid}/Conversations/{conversation_sid}/Messages/{message_sid}/Receipts/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(self) -> DeliveryReceiptInstance:
|
||||
"""
|
||||
Fetch the DeliveryReceiptInstance
|
||||
|
||||
|
||||
:returns: The fetched DeliveryReceiptInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return DeliveryReceiptInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
message_sid=self._solution["message_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> DeliveryReceiptInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the DeliveryReceiptInstance
|
||||
|
||||
|
||||
:returns: The fetched DeliveryReceiptInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return DeliveryReceiptInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
message_sid=self._solution["message_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.DeliveryReceiptContext {}>".format(context)
|
||||
|
||||
|
||||
class DeliveryReceiptPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> DeliveryReceiptInstance:
|
||||
"""
|
||||
Build an instance of DeliveryReceiptInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return DeliveryReceiptInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
message_sid=self._solution["message_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.DeliveryReceiptPage>"
|
||||
|
||||
|
||||
class DeliveryReceiptList(ListResource):
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
chat_service_sid: str,
|
||||
conversation_sid: str,
|
||||
message_sid: str,
|
||||
):
|
||||
"""
|
||||
Initialize the DeliveryReceiptList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Message resource is associated with.
|
||||
:param conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this message.
|
||||
:param message_sid: The SID of the message within a [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) the delivery receipt belongs to.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"conversation_sid": conversation_sid,
|
||||
"message_sid": message_sid,
|
||||
}
|
||||
self._uri = "/Services/{chat_service_sid}/Conversations/{conversation_sid}/Messages/{message_sid}/Receipts".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[DeliveryReceiptInstance]:
|
||||
"""
|
||||
Streams DeliveryReceiptInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[DeliveryReceiptInstance]:
|
||||
"""
|
||||
Asynchronously streams DeliveryReceiptInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[DeliveryReceiptInstance]:
|
||||
"""
|
||||
Lists DeliveryReceiptInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[DeliveryReceiptInstance]:
|
||||
"""
|
||||
Asynchronously lists DeliveryReceiptInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> DeliveryReceiptPage:
|
||||
"""
|
||||
Retrieve a single page of DeliveryReceiptInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of DeliveryReceiptInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return DeliveryReceiptPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> DeliveryReceiptPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of DeliveryReceiptInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of DeliveryReceiptInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return DeliveryReceiptPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> DeliveryReceiptPage:
|
||||
"""
|
||||
Retrieve a specific page of DeliveryReceiptInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of DeliveryReceiptInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return DeliveryReceiptPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> DeliveryReceiptPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of DeliveryReceiptInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of DeliveryReceiptInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return DeliveryReceiptPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> DeliveryReceiptContext:
|
||||
"""
|
||||
Constructs a DeliveryReceiptContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return DeliveryReceiptContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
message_sid=self._solution["message_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> DeliveryReceiptContext:
|
||||
"""
|
||||
Constructs a DeliveryReceiptContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return DeliveryReceiptContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
message_sid=self._solution["message_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.DeliveryReceiptList>"
|
||||
+870
@@ -0,0 +1,870 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
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.page import Page
|
||||
|
||||
|
||||
class ParticipantInstance(InstanceResource):
|
||||
class WebhookEnabledType(object):
|
||||
TRUE = "true"
|
||||
FALSE = "false"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this participant.
|
||||
:ivar chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Participant resource is associated with.
|
||||
:ivar conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this participant.
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the [Conversation SDK](https://www.twilio.com/docs/conversations/sdk-overview) to communicate. Limited to 256 characters.
|
||||
:ivar attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set `{}` will be returned.
|
||||
:ivar messaging_binding: Information about how this participant exchanges messages with the conversation. A JSON parameter consisting of type and address fields of the participant.
|
||||
:ivar role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant.
|
||||
:ivar date_created: The date on which this resource was created.
|
||||
:ivar date_updated: The date on which this resource was last updated.
|
||||
:ivar url: An absolute API resource URL for this participant.
|
||||
:ivar last_read_message_index: Index of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.
|
||||
:ivar last_read_timestamp: Timestamp of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
chat_service_sid: str,
|
||||
conversation_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.chat_service_sid: Optional[str] = payload.get("chat_service_sid")
|
||||
self.conversation_sid: Optional[str] = payload.get("conversation_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.identity: Optional[str] = payload.get("identity")
|
||||
self.attributes: Optional[str] = payload.get("attributes")
|
||||
self.messaging_binding: Optional[Dict[str, object]] = payload.get(
|
||||
"messaging_binding"
|
||||
)
|
||||
self.role_sid: Optional[str] = payload.get("role_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.last_read_message_index: Optional[int] = deserialize.integer(
|
||||
payload.get("last_read_message_index")
|
||||
)
|
||||
self.last_read_timestamp: Optional[str] = payload.get("last_read_timestamp")
|
||||
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"conversation_sid": conversation_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[ParticipantContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "ParticipantContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: ParticipantContext for this ParticipantInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = ParticipantContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ParticipantInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Deletes the ParticipantInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
)
|
||||
|
||||
async def delete_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ParticipantInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ParticipantInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
)
|
||||
|
||||
def fetch(self) -> "ParticipantInstance":
|
||||
"""
|
||||
Fetch the ParticipantInstance
|
||||
|
||||
|
||||
:returns: The fetched ParticipantInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "ParticipantInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ParticipantInstance
|
||||
|
||||
|
||||
:returns: The fetched ParticipantInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ParticipantInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
identity: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
messaging_binding_proxy_address: Union[str, object] = values.unset,
|
||||
messaging_binding_projected_address: Union[str, object] = values.unset,
|
||||
last_read_message_index: Union[int, object] = values.unset,
|
||||
last_read_timestamp: Union[str, object] = values.unset,
|
||||
) -> "ParticipantInstance":
|
||||
"""
|
||||
Update the ParticipantInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param date_created: The date on which this resource was created.
|
||||
:param date_updated: The date on which this resource was last updated.
|
||||
:param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the [Conversation SDK](https://www.twilio.com/docs/conversations/sdk-overview) to communicate. Limited to 256 characters.
|
||||
:param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set `{}` will be returned.
|
||||
:param role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant.
|
||||
:param messaging_binding_proxy_address: The address of the Twilio phone number that the participant is in contact with. 'null' value will remove it.
|
||||
:param messaging_binding_projected_address: The address of the Twilio phone number that is used in Group MMS. 'null' value will remove it.
|
||||
:param last_read_message_index: Index of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.
|
||||
:param last_read_timestamp: Timestamp of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.
|
||||
|
||||
:returns: The updated ParticipantInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
date_created=date_created,
|
||||
date_updated=date_updated,
|
||||
identity=identity,
|
||||
attributes=attributes,
|
||||
role_sid=role_sid,
|
||||
messaging_binding_proxy_address=messaging_binding_proxy_address,
|
||||
messaging_binding_projected_address=messaging_binding_projected_address,
|
||||
last_read_message_index=last_read_message_index,
|
||||
last_read_timestamp=last_read_timestamp,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ParticipantInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
identity: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
messaging_binding_proxy_address: Union[str, object] = values.unset,
|
||||
messaging_binding_projected_address: Union[str, object] = values.unset,
|
||||
last_read_message_index: Union[int, object] = values.unset,
|
||||
last_read_timestamp: Union[str, object] = values.unset,
|
||||
) -> "ParticipantInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the ParticipantInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param date_created: The date on which this resource was created.
|
||||
:param date_updated: The date on which this resource was last updated.
|
||||
:param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the [Conversation SDK](https://www.twilio.com/docs/conversations/sdk-overview) to communicate. Limited to 256 characters.
|
||||
:param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set `{}` will be returned.
|
||||
:param role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant.
|
||||
:param messaging_binding_proxy_address: The address of the Twilio phone number that the participant is in contact with. 'null' value will remove it.
|
||||
:param messaging_binding_projected_address: The address of the Twilio phone number that is used in Group MMS. 'null' value will remove it.
|
||||
:param last_read_message_index: Index of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.
|
||||
:param last_read_timestamp: Timestamp of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.
|
||||
|
||||
:returns: The updated ParticipantInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
date_created=date_created,
|
||||
date_updated=date_updated,
|
||||
identity=identity,
|
||||
attributes=attributes,
|
||||
role_sid=role_sid,
|
||||
messaging_binding_proxy_address=messaging_binding_proxy_address,
|
||||
messaging_binding_projected_address=messaging_binding_projected_address,
|
||||
last_read_message_index=last_read_message_index,
|
||||
last_read_timestamp=last_read_timestamp,
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.ParticipantInstance {}>".format(context)
|
||||
|
||||
|
||||
class ParticipantContext(InstanceContext):
|
||||
def __init__(
|
||||
self, version: Version, chat_service_sid: str, conversation_sid: str, sid: str
|
||||
):
|
||||
"""
|
||||
Initialize the ParticipantContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Participant resource is associated with.
|
||||
:param conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this participant.
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"conversation_sid": conversation_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Services/{chat_service_sid}/Conversations/{conversation_sid}/Participants/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ParticipantInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Deletes the ParticipantInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
return self._version.delete(method="DELETE", uri=self._uri, headers=headers)
|
||||
|
||||
async def delete_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ParticipantInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ParticipantInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
return await self._version.delete_async(
|
||||
method="DELETE", uri=self._uri, headers=headers
|
||||
)
|
||||
|
||||
def fetch(self) -> ParticipantInstance:
|
||||
"""
|
||||
Fetch the ParticipantInstance
|
||||
|
||||
|
||||
:returns: The fetched ParticipantInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ParticipantInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> ParticipantInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ParticipantInstance
|
||||
|
||||
|
||||
:returns: The fetched ParticipantInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ParticipantInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ParticipantInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
identity: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
messaging_binding_proxy_address: Union[str, object] = values.unset,
|
||||
messaging_binding_projected_address: Union[str, object] = values.unset,
|
||||
last_read_message_index: Union[int, object] = values.unset,
|
||||
last_read_timestamp: Union[str, object] = values.unset,
|
||||
) -> ParticipantInstance:
|
||||
"""
|
||||
Update the ParticipantInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param date_created: The date on which this resource was created.
|
||||
:param date_updated: The date on which this resource was last updated.
|
||||
:param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the [Conversation SDK](https://www.twilio.com/docs/conversations/sdk-overview) to communicate. Limited to 256 characters.
|
||||
:param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set `{}` will be returned.
|
||||
:param role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant.
|
||||
:param messaging_binding_proxy_address: The address of the Twilio phone number that the participant is in contact with. 'null' value will remove it.
|
||||
:param messaging_binding_projected_address: The address of the Twilio phone number that is used in Group MMS. 'null' value will remove it.
|
||||
:param last_read_message_index: Index of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.
|
||||
:param last_read_timestamp: Timestamp of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.
|
||||
|
||||
:returns: The updated ParticipantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateUpdated": serialize.iso8601_datetime(date_updated),
|
||||
"Identity": identity,
|
||||
"Attributes": attributes,
|
||||
"RoleSid": role_sid,
|
||||
"MessagingBinding.ProxyAddress": messaging_binding_proxy_address,
|
||||
"MessagingBinding.ProjectedAddress": messaging_binding_projected_address,
|
||||
"LastReadMessageIndex": last_read_message_index,
|
||||
"LastReadTimestamp": last_read_timestamp,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return ParticipantInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ParticipantInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
identity: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
messaging_binding_proxy_address: Union[str, object] = values.unset,
|
||||
messaging_binding_projected_address: Union[str, object] = values.unset,
|
||||
last_read_message_index: Union[int, object] = values.unset,
|
||||
last_read_timestamp: Union[str, object] = values.unset,
|
||||
) -> ParticipantInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the ParticipantInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param date_created: The date on which this resource was created.
|
||||
:param date_updated: The date on which this resource was last updated.
|
||||
:param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the [Conversation SDK](https://www.twilio.com/docs/conversations/sdk-overview) to communicate. Limited to 256 characters.
|
||||
:param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set `{}` will be returned.
|
||||
:param role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant.
|
||||
:param messaging_binding_proxy_address: The address of the Twilio phone number that the participant is in contact with. 'null' value will remove it.
|
||||
:param messaging_binding_projected_address: The address of the Twilio phone number that is used in Group MMS. 'null' value will remove it.
|
||||
:param last_read_message_index: Index of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.
|
||||
:param last_read_timestamp: Timestamp of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.
|
||||
|
||||
:returns: The updated ParticipantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateUpdated": serialize.iso8601_datetime(date_updated),
|
||||
"Identity": identity,
|
||||
"Attributes": attributes,
|
||||
"RoleSid": role_sid,
|
||||
"MessagingBinding.ProxyAddress": messaging_binding_proxy_address,
|
||||
"MessagingBinding.ProjectedAddress": messaging_binding_projected_address,
|
||||
"LastReadMessageIndex": last_read_message_index,
|
||||
"LastReadTimestamp": last_read_timestamp,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return ParticipantInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.ParticipantContext {}>".format(context)
|
||||
|
||||
|
||||
class ParticipantPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> ParticipantInstance:
|
||||
"""
|
||||
Build an instance of ParticipantInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return ParticipantInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.ParticipantPage>"
|
||||
|
||||
|
||||
class ParticipantList(ListResource):
|
||||
def __init__(self, version: Version, chat_service_sid: str, conversation_sid: str):
|
||||
"""
|
||||
Initialize the ParticipantList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Participant resource is associated with.
|
||||
:param conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for participants.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"conversation_sid": conversation_sid,
|
||||
}
|
||||
self._uri = "/Services/{chat_service_sid}/Conversations/{conversation_sid}/Participants".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ParticipantInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
identity: Union[str, object] = values.unset,
|
||||
messaging_binding_address: Union[str, object] = values.unset,
|
||||
messaging_binding_proxy_address: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
messaging_binding_projected_address: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
) -> ParticipantInstance:
|
||||
"""
|
||||
Create the ParticipantInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the [Conversation SDK](https://www.twilio.com/docs/conversations/sdk-overview) to communicate. Limited to 256 characters.
|
||||
:param messaging_binding_address: The address of the participant's device, e.g. a phone or WhatsApp number. Together with the Proxy address, this determines a participant uniquely. This field (with `proxy_address`) is only null when the participant is interacting from an SDK endpoint (see the `identity` field).
|
||||
:param messaging_binding_proxy_address: The address of the Twilio phone number (or WhatsApp number) that the participant is in contact with. This field, together with participant address, is only null when the participant is interacting from an SDK endpoint (see the `identity` field).
|
||||
:param date_created: The date on which this resource was created.
|
||||
:param date_updated: The date on which this resource was last updated.
|
||||
:param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set `{}` will be returned.
|
||||
:param messaging_binding_projected_address: The address of the Twilio phone number that is used in Group MMS.
|
||||
:param role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant.
|
||||
|
||||
:returns: The created ParticipantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Identity": identity,
|
||||
"MessagingBinding.Address": messaging_binding_address,
|
||||
"MessagingBinding.ProxyAddress": messaging_binding_proxy_address,
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateUpdated": serialize.iso8601_datetime(date_updated),
|
||||
"Attributes": attributes,
|
||||
"MessagingBinding.ProjectedAddress": messaging_binding_projected_address,
|
||||
"RoleSid": role_sid,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
payload = self._version.create(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return ParticipantInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"ParticipantInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
identity: Union[str, object] = values.unset,
|
||||
messaging_binding_address: Union[str, object] = values.unset,
|
||||
messaging_binding_proxy_address: Union[str, object] = values.unset,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_updated: Union[datetime, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
messaging_binding_projected_address: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
) -> ParticipantInstance:
|
||||
"""
|
||||
Asynchronously create the ParticipantInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the [Conversation SDK](https://www.twilio.com/docs/conversations/sdk-overview) to communicate. Limited to 256 characters.
|
||||
:param messaging_binding_address: The address of the participant's device, e.g. a phone or WhatsApp number. Together with the Proxy address, this determines a participant uniquely. This field (with `proxy_address`) is only null when the participant is interacting from an SDK endpoint (see the `identity` field).
|
||||
:param messaging_binding_proxy_address: The address of the Twilio phone number (or WhatsApp number) that the participant is in contact with. This field, together with participant address, is only null when the participant is interacting from an SDK endpoint (see the `identity` field).
|
||||
:param date_created: The date on which this resource was created.
|
||||
:param date_updated: The date on which this resource was last updated.
|
||||
:param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set `{}` will be returned.
|
||||
:param messaging_binding_projected_address: The address of the Twilio phone number that is used in Group MMS.
|
||||
:param role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant.
|
||||
|
||||
:returns: The created ParticipantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Identity": identity,
|
||||
"MessagingBinding.Address": messaging_binding_address,
|
||||
"MessagingBinding.ProxyAddress": messaging_binding_proxy_address,
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateUpdated": serialize.iso8601_datetime(date_updated),
|
||||
"Attributes": attributes,
|
||||
"MessagingBinding.ProjectedAddress": messaging_binding_projected_address,
|
||||
"RoleSid": role_sid,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
payload = await self._version.create_async(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return ParticipantInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[ParticipantInstance]:
|
||||
"""
|
||||
Streams ParticipantInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[ParticipantInstance]:
|
||||
"""
|
||||
Asynchronously streams ParticipantInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ParticipantInstance]:
|
||||
"""
|
||||
Lists ParticipantInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ParticipantInstance]:
|
||||
"""
|
||||
Asynchronously lists ParticipantInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ParticipantPage:
|
||||
"""
|
||||
Retrieve a single page of ParticipantInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of ParticipantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return ParticipantPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ParticipantPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of ParticipantInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of ParticipantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return ParticipantPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> ParticipantPage:
|
||||
"""
|
||||
Retrieve a specific page of ParticipantInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ParticipantInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return ParticipantPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> ParticipantPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of ParticipantInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ParticipantInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return ParticipantPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> ParticipantContext:
|
||||
"""
|
||||
Constructs a ParticipantContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return ParticipantContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> ParticipantContext:
|
||||
"""
|
||||
Constructs a ParticipantContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return ParticipantContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.ParticipantList>"
|
||||
+753
@@ -0,0 +1,753 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
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.page import Page
|
||||
|
||||
|
||||
class WebhookInstance(InstanceResource):
|
||||
class Method(object):
|
||||
GET = "GET"
|
||||
POST = "POST"
|
||||
|
||||
class Target(object):
|
||||
WEBHOOK = "webhook"
|
||||
TRIGGER = "trigger"
|
||||
STUDIO = "studio"
|
||||
|
||||
"""
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this conversation.
|
||||
:ivar chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Participant resource is associated with.
|
||||
:ivar conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this webhook.
|
||||
:ivar target: The target of this webhook: `webhook`, `studio`, `trigger`
|
||||
:ivar url: An absolute API resource URL for this webhook.
|
||||
:ivar configuration: The configuration of this webhook. Is defined based on target.
|
||||
:ivar date_created: The date that this resource was created.
|
||||
:ivar date_updated: The date that this resource was last updated.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
chat_service_sid: str,
|
||||
conversation_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.chat_service_sid: Optional[str] = payload.get("chat_service_sid")
|
||||
self.conversation_sid: Optional[str] = payload.get("conversation_sid")
|
||||
self.target: Optional[str] = payload.get("target")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.configuration: Optional[Dict[str, object]] = payload.get("configuration")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"conversation_sid": conversation_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[WebhookContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "WebhookContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: WebhookContext for this WebhookInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = WebhookContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the WebhookInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the WebhookInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "WebhookInstance":
|
||||
"""
|
||||
Fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "WebhookInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
configuration_url: Union[str, object] = values.unset,
|
||||
configuration_method: Union["WebhookInstance.Method", object] = values.unset,
|
||||
configuration_filters: Union[List[str], object] = values.unset,
|
||||
configuration_triggers: Union[List[str], object] = values.unset,
|
||||
configuration_flow_sid: Union[str, object] = values.unset,
|
||||
) -> "WebhookInstance":
|
||||
"""
|
||||
Update the WebhookInstance
|
||||
|
||||
:param configuration_url: The absolute url the webhook request should be sent to.
|
||||
:param configuration_method:
|
||||
:param configuration_filters: The list of events, firing webhook event for this Conversation.
|
||||
:param configuration_triggers: The list of keywords, firing webhook event for this Conversation.
|
||||
:param configuration_flow_sid: The studio flow SID, where the webhook should be sent to.
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
configuration_url=configuration_url,
|
||||
configuration_method=configuration_method,
|
||||
configuration_filters=configuration_filters,
|
||||
configuration_triggers=configuration_triggers,
|
||||
configuration_flow_sid=configuration_flow_sid,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
configuration_url: Union[str, object] = values.unset,
|
||||
configuration_method: Union["WebhookInstance.Method", object] = values.unset,
|
||||
configuration_filters: Union[List[str], object] = values.unset,
|
||||
configuration_triggers: Union[List[str], object] = values.unset,
|
||||
configuration_flow_sid: Union[str, object] = values.unset,
|
||||
) -> "WebhookInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the WebhookInstance
|
||||
|
||||
:param configuration_url: The absolute url the webhook request should be sent to.
|
||||
:param configuration_method:
|
||||
:param configuration_filters: The list of events, firing webhook event for this Conversation.
|
||||
:param configuration_triggers: The list of keywords, firing webhook event for this Conversation.
|
||||
:param configuration_flow_sid: The studio flow SID, where the webhook should be sent to.
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
configuration_url=configuration_url,
|
||||
configuration_method=configuration_method,
|
||||
configuration_filters=configuration_filters,
|
||||
configuration_triggers=configuration_triggers,
|
||||
configuration_flow_sid=configuration_flow_sid,
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.WebhookInstance {}>".format(context)
|
||||
|
||||
|
||||
class WebhookContext(InstanceContext):
|
||||
def __init__(
|
||||
self, version: Version, chat_service_sid: str, conversation_sid: str, sid: str
|
||||
):
|
||||
"""
|
||||
Initialize the WebhookContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Participant resource is associated with.
|
||||
:param conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this webhook.
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"conversation_sid": conversation_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Services/{chat_service_sid}/Conversations/{conversation_sid}/Webhooks/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the WebhookInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the WebhookInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> WebhookInstance:
|
||||
"""
|
||||
Fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> WebhookInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
configuration_url: Union[str, object] = values.unset,
|
||||
configuration_method: Union["WebhookInstance.Method", object] = values.unset,
|
||||
configuration_filters: Union[List[str], object] = values.unset,
|
||||
configuration_triggers: Union[List[str], object] = values.unset,
|
||||
configuration_flow_sid: Union[str, object] = values.unset,
|
||||
) -> WebhookInstance:
|
||||
"""
|
||||
Update the WebhookInstance
|
||||
|
||||
:param configuration_url: The absolute url the webhook request should be sent to.
|
||||
:param configuration_method:
|
||||
:param configuration_filters: The list of events, firing webhook event for this Conversation.
|
||||
:param configuration_triggers: The list of keywords, firing webhook event for this Conversation.
|
||||
:param configuration_flow_sid: The studio flow SID, where the webhook should be sent to.
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Configuration.Url": configuration_url,
|
||||
"Configuration.Method": configuration_method,
|
||||
"Configuration.Filters": serialize.map(
|
||||
configuration_filters, lambda e: e
|
||||
),
|
||||
"Configuration.Triggers": serialize.map(
|
||||
configuration_triggers, lambda e: e
|
||||
),
|
||||
"Configuration.FlowSid": configuration_flow_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
configuration_url: Union[str, object] = values.unset,
|
||||
configuration_method: Union["WebhookInstance.Method", object] = values.unset,
|
||||
configuration_filters: Union[List[str], object] = values.unset,
|
||||
configuration_triggers: Union[List[str], object] = values.unset,
|
||||
configuration_flow_sid: Union[str, object] = values.unset,
|
||||
) -> WebhookInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the WebhookInstance
|
||||
|
||||
:param configuration_url: The absolute url the webhook request should be sent to.
|
||||
:param configuration_method:
|
||||
:param configuration_filters: The list of events, firing webhook event for this Conversation.
|
||||
:param configuration_triggers: The list of keywords, firing webhook event for this Conversation.
|
||||
:param configuration_flow_sid: The studio flow SID, where the webhook should be sent to.
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Configuration.Url": configuration_url,
|
||||
"Configuration.Method": configuration_method,
|
||||
"Configuration.Filters": serialize.map(
|
||||
configuration_filters, lambda e: e
|
||||
),
|
||||
"Configuration.Triggers": serialize.map(
|
||||
configuration_triggers, lambda e: e
|
||||
),
|
||||
"Configuration.FlowSid": configuration_flow_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.WebhookContext {}>".format(context)
|
||||
|
||||
|
||||
class WebhookPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> WebhookInstance:
|
||||
"""
|
||||
Build an instance of WebhookInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.WebhookPage>"
|
||||
|
||||
|
||||
class WebhookList(ListResource):
|
||||
def __init__(self, version: Version, chat_service_sid: str, conversation_sid: str):
|
||||
"""
|
||||
Initialize the WebhookList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Participant resource is associated with.
|
||||
:param conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this webhook.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"conversation_sid": conversation_sid,
|
||||
}
|
||||
self._uri = "/Services/{chat_service_sid}/Conversations/{conversation_sid}/Webhooks".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self,
|
||||
target: "WebhookInstance.Target",
|
||||
configuration_url: Union[str, object] = values.unset,
|
||||
configuration_method: Union["WebhookInstance.Method", object] = values.unset,
|
||||
configuration_filters: Union[List[str], object] = values.unset,
|
||||
configuration_triggers: Union[List[str], object] = values.unset,
|
||||
configuration_flow_sid: Union[str, object] = values.unset,
|
||||
configuration_replay_after: Union[int, object] = values.unset,
|
||||
) -> WebhookInstance:
|
||||
"""
|
||||
Create the WebhookInstance
|
||||
|
||||
:param target:
|
||||
:param configuration_url: The absolute url the webhook request should be sent to.
|
||||
:param configuration_method:
|
||||
:param configuration_filters: The list of events, firing webhook event for this Conversation.
|
||||
:param configuration_triggers: The list of keywords, firing webhook event for this Conversation.
|
||||
:param configuration_flow_sid: The studio flow SID, where the webhook should be sent to.
|
||||
:param configuration_replay_after: The message index for which and it's successors the webhook will be replayed. Not set by default
|
||||
|
||||
:returns: The created WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Target": target,
|
||||
"Configuration.Url": configuration_url,
|
||||
"Configuration.Method": configuration_method,
|
||||
"Configuration.Filters": serialize.map(
|
||||
configuration_filters, lambda e: e
|
||||
),
|
||||
"Configuration.Triggers": serialize.map(
|
||||
configuration_triggers, lambda e: e
|
||||
),
|
||||
"Configuration.FlowSid": configuration_flow_sid,
|
||||
"Configuration.ReplayAfter": configuration_replay_after,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
target: "WebhookInstance.Target",
|
||||
configuration_url: Union[str, object] = values.unset,
|
||||
configuration_method: Union["WebhookInstance.Method", object] = values.unset,
|
||||
configuration_filters: Union[List[str], object] = values.unset,
|
||||
configuration_triggers: Union[List[str], object] = values.unset,
|
||||
configuration_flow_sid: Union[str, object] = values.unset,
|
||||
configuration_replay_after: Union[int, object] = values.unset,
|
||||
) -> WebhookInstance:
|
||||
"""
|
||||
Asynchronously create the WebhookInstance
|
||||
|
||||
:param target:
|
||||
:param configuration_url: The absolute url the webhook request should be sent to.
|
||||
:param configuration_method:
|
||||
:param configuration_filters: The list of events, firing webhook event for this Conversation.
|
||||
:param configuration_triggers: The list of keywords, firing webhook event for this Conversation.
|
||||
:param configuration_flow_sid: The studio flow SID, where the webhook should be sent to.
|
||||
:param configuration_replay_after: The message index for which and it's successors the webhook will be replayed. Not set by default
|
||||
|
||||
:returns: The created WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Target": target,
|
||||
"Configuration.Url": configuration_url,
|
||||
"Configuration.Method": configuration_method,
|
||||
"Configuration.Filters": serialize.map(
|
||||
configuration_filters, lambda e: e
|
||||
),
|
||||
"Configuration.Triggers": serialize.map(
|
||||
configuration_triggers, lambda e: e
|
||||
),
|
||||
"Configuration.FlowSid": configuration_flow_sid,
|
||||
"Configuration.ReplayAfter": configuration_replay_after,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[WebhookInstance]:
|
||||
"""
|
||||
Streams WebhookInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[WebhookInstance]:
|
||||
"""
|
||||
Asynchronously streams WebhookInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[WebhookInstance]:
|
||||
"""
|
||||
Lists WebhookInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[WebhookInstance]:
|
||||
"""
|
||||
Asynchronously lists WebhookInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> WebhookPage:
|
||||
"""
|
||||
Retrieve a single page of WebhookInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return WebhookPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> WebhookPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of WebhookInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return WebhookPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> WebhookPage:
|
||||
"""
|
||||
Retrieve a specific page of WebhookInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of WebhookInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return WebhookPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> WebhookPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of WebhookInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of WebhookInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return WebhookPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> WebhookContext:
|
||||
"""
|
||||
Constructs a WebhookContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return WebhookContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> WebhookContext:
|
||||
"""
|
||||
Constructs a WebhookContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return WebhookContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.WebhookList>"
|
||||
+371
@@ -0,0 +1,371 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class ParticipantConversationInstance(InstanceResource):
|
||||
class State(object):
|
||||
INACTIVE = "inactive"
|
||||
ACTIVE = "active"
|
||||
CLOSED = "closed"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this conversation.
|
||||
:ivar chat_service_sid: The unique ID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation belongs to.
|
||||
:ivar participant_sid: The unique ID of the [Participant](https://www.twilio.com/docs/conversations/api/conversation-participant-resource).
|
||||
:ivar participant_user_sid: The unique string that identifies the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource).
|
||||
:ivar participant_identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:ivar participant_messaging_binding: Information about how this participant exchanges messages with the conversation. A JSON parameter consisting of type and address fields of the participant.
|
||||
:ivar conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) this Participant belongs to.
|
||||
:ivar conversation_unique_name: An application-defined string that uniquely identifies the Conversation resource.
|
||||
:ivar conversation_friendly_name: The human-readable name of this conversation, limited to 256 characters. Optional.
|
||||
:ivar conversation_attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \"{}\" will be returned.
|
||||
:ivar conversation_date_created: The date that this conversation was created, given in ISO 8601 format.
|
||||
:ivar conversation_date_updated: The date that this conversation was last updated, given in ISO 8601 format.
|
||||
:ivar conversation_created_by: Identity of the creator of this Conversation.
|
||||
:ivar conversation_state:
|
||||
:ivar conversation_timers: Timer date values representing state update for this conversation.
|
||||
:ivar links: Contains absolute URLs to access the [participant](https://www.twilio.com/docs/conversations/api/conversation-participant-resource) and [conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) of this conversation.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], chat_service_sid: str
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.chat_service_sid: Optional[str] = payload.get("chat_service_sid")
|
||||
self.participant_sid: Optional[str] = payload.get("participant_sid")
|
||||
self.participant_user_sid: Optional[str] = payload.get("participant_user_sid")
|
||||
self.participant_identity: Optional[str] = payload.get("participant_identity")
|
||||
self.participant_messaging_binding: Optional[Dict[str, object]] = payload.get(
|
||||
"participant_messaging_binding"
|
||||
)
|
||||
self.conversation_sid: Optional[str] = payload.get("conversation_sid")
|
||||
self.conversation_unique_name: Optional[str] = payload.get(
|
||||
"conversation_unique_name"
|
||||
)
|
||||
self.conversation_friendly_name: Optional[str] = payload.get(
|
||||
"conversation_friendly_name"
|
||||
)
|
||||
self.conversation_attributes: Optional[str] = payload.get(
|
||||
"conversation_attributes"
|
||||
)
|
||||
self.conversation_date_created: Optional[
|
||||
datetime
|
||||
] = deserialize.iso8601_datetime(payload.get("conversation_date_created"))
|
||||
self.conversation_date_updated: Optional[
|
||||
datetime
|
||||
] = deserialize.iso8601_datetime(payload.get("conversation_date_updated"))
|
||||
self.conversation_created_by: Optional[str] = payload.get(
|
||||
"conversation_created_by"
|
||||
)
|
||||
self.conversation_state: Optional[
|
||||
"ParticipantConversationInstance.State"
|
||||
] = payload.get("conversation_state")
|
||||
self.conversation_timers: Optional[Dict[str, object]] = payload.get(
|
||||
"conversation_timers"
|
||||
)
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
}
|
||||
|
||||
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 "<Twilio.Conversations.V1.ParticipantConversationInstance {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class ParticipantConversationPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> ParticipantConversationInstance:
|
||||
"""
|
||||
Build an instance of ParticipantConversationInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return ParticipantConversationInstance(
|
||||
self._version, payload, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.ParticipantConversationPage>"
|
||||
|
||||
|
||||
class ParticipantConversationList(ListResource):
|
||||
def __init__(self, version: Version, chat_service_sid: str):
|
||||
"""
|
||||
Initialize the ParticipantConversationList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Participant Conversations resource is associated with.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
}
|
||||
self._uri = "/Services/{chat_service_sid}/ParticipantConversations".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
identity: Union[str, object] = values.unset,
|
||||
address: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[ParticipantConversationInstance]:
|
||||
"""
|
||||
Streams ParticipantConversationInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:param str address: A unique string identifier for the conversation participant who's not a Conversation User. This parameter could be found in messaging_binding.address field of Participant resource. It should be url-encoded.
|
||||
: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(
|
||||
identity=identity, address=address, page_size=limits["page_size"]
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
identity: Union[str, object] = values.unset,
|
||||
address: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[ParticipantConversationInstance]:
|
||||
"""
|
||||
Asynchronously streams ParticipantConversationInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:param str address: A unique string identifier for the conversation participant who's not a Conversation User. This parameter could be found in messaging_binding.address field of Participant resource. It should be url-encoded.
|
||||
: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(
|
||||
identity=identity, address=address, page_size=limits["page_size"]
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
identity: Union[str, object] = values.unset,
|
||||
address: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ParticipantConversationInstance]:
|
||||
"""
|
||||
Lists ParticipantConversationInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:param str address: A unique string identifier for the conversation participant who's not a Conversation User. This parameter could be found in messaging_binding.address field of Participant resource. It should be url-encoded.
|
||||
: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(
|
||||
identity=identity,
|
||||
address=address,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
identity: Union[str, object] = values.unset,
|
||||
address: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ParticipantConversationInstance]:
|
||||
"""
|
||||
Asynchronously lists ParticipantConversationInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:param str address: A unique string identifier for the conversation participant who's not a Conversation User. This parameter could be found in messaging_binding.address field of Participant resource. It should be url-encoded.
|
||||
: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(
|
||||
identity=identity,
|
||||
address=address,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
identity: Union[str, object] = values.unset,
|
||||
address: 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,
|
||||
) -> ParticipantConversationPage:
|
||||
"""
|
||||
Retrieve a single page of ParticipantConversationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:param address: A unique string identifier for the conversation participant who's not a Conversation User. This parameter could be found in messaging_binding.address field of Participant resource. It should be url-encoded.
|
||||
: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: Page of ParticipantConversationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Identity": identity,
|
||||
"Address": address,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return ParticipantConversationPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
identity: Union[str, object] = values.unset,
|
||||
address: 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,
|
||||
) -> ParticipantConversationPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of ParticipantConversationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.
|
||||
:param address: A unique string identifier for the conversation participant who's not a Conversation User. This parameter could be found in messaging_binding.address field of Participant resource. It should be url-encoded.
|
||||
: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: Page of ParticipantConversationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Identity": identity,
|
||||
"Address": address,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return ParticipantConversationPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> ParticipantConversationPage:
|
||||
"""
|
||||
Retrieve a specific page of ParticipantConversationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ParticipantConversationInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return ParticipantConversationPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> ParticipantConversationPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of ParticipantConversationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ParticipantConversationInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return ParticipantConversationPage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.ParticipantConversationList>"
|
||||
@@ -0,0 +1,610 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
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.page import Page
|
||||
|
||||
|
||||
class RoleInstance(InstanceResource):
|
||||
class RoleType(object):
|
||||
CONVERSATION = "conversation"
|
||||
SERVICE = "service"
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that we created to identify the Role resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Role resource.
|
||||
:ivar chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Role resource is associated with.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar type:
|
||||
:ivar permissions: An array of the permissions the role has been granted.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar url: An absolute API resource URL for this user role.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
chat_service_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.chat_service_sid: Optional[str] = payload.get("chat_service_sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.type: Optional["RoleInstance.RoleType"] = payload.get("type")
|
||||
self.permissions: Optional[List[str]] = payload.get("permissions")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[RoleContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "RoleContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: RoleContext for this RoleInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = RoleContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the RoleInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the RoleInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "RoleInstance":
|
||||
"""
|
||||
Fetch the RoleInstance
|
||||
|
||||
|
||||
:returns: The fetched RoleInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "RoleInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the RoleInstance
|
||||
|
||||
|
||||
:returns: The fetched RoleInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(self, permission: List[str]) -> "RoleInstance":
|
||||
"""
|
||||
Update the RoleInstance
|
||||
|
||||
:param permission: A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. Note that the update action replaces all previously assigned permissions with those defined in the update action. To remove a permission, do not include it in the subsequent update action. The values for this parameter depend on the role's `type`.
|
||||
|
||||
:returns: The updated RoleInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
permission=permission,
|
||||
)
|
||||
|
||||
async def update_async(self, permission: List[str]) -> "RoleInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the RoleInstance
|
||||
|
||||
:param permission: A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. Note that the update action replaces all previously assigned permissions with those defined in the update action. To remove a permission, do not include it in the subsequent update action. The values for this parameter depend on the role's `type`.
|
||||
|
||||
:returns: The updated RoleInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
permission=permission,
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.RoleInstance {}>".format(context)
|
||||
|
||||
|
||||
class RoleContext(InstanceContext):
|
||||
def __init__(self, version: Version, chat_service_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the RoleContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) to update the Role resource in.
|
||||
:param sid: The SID of the Role resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Services/{chat_service_sid}/Roles/{sid}".format(**self._solution)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the RoleInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the RoleInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> RoleInstance:
|
||||
"""
|
||||
Fetch the RoleInstance
|
||||
|
||||
|
||||
:returns: The fetched RoleInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return RoleInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> RoleInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the RoleInstance
|
||||
|
||||
|
||||
:returns: The fetched RoleInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return RoleInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(self, permission: List[str]) -> RoleInstance:
|
||||
"""
|
||||
Update the RoleInstance
|
||||
|
||||
:param permission: A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. Note that the update action replaces all previously assigned permissions with those defined in the update action. To remove a permission, do not include it in the subsequent update action. The values for this parameter depend on the role's `type`.
|
||||
|
||||
:returns: The updated RoleInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Permission": serialize.map(permission, lambda e: e),
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RoleInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(self, permission: List[str]) -> RoleInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the RoleInstance
|
||||
|
||||
:param permission: A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. Note that the update action replaces all previously assigned permissions with those defined in the update action. To remove a permission, do not include it in the subsequent update action. The values for this parameter depend on the role's `type`.
|
||||
|
||||
:returns: The updated RoleInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Permission": serialize.map(permission, lambda e: e),
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RoleInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.RoleContext {}>".format(context)
|
||||
|
||||
|
||||
class RolePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> RoleInstance:
|
||||
"""
|
||||
Build an instance of RoleInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return RoleInstance(
|
||||
self._version, payload, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.RolePage>"
|
||||
|
||||
|
||||
class RoleList(ListResource):
|
||||
def __init__(self, version: Version, chat_service_sid: str):
|
||||
"""
|
||||
Initialize the RoleList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) to read the Role resources from.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
}
|
||||
self._uri = "/Services/{chat_service_sid}/Roles".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self, friendly_name: str, type: "RoleInstance.RoleType", permission: List[str]
|
||||
) -> RoleInstance:
|
||||
"""
|
||||
Create the RoleInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the new resource. It can be up to 64 characters long.
|
||||
:param type:
|
||||
:param permission: A permission that you grant to the new role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. The values for this parameter depend on the role's `type`.
|
||||
|
||||
:returns: The created RoleInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"Type": type,
|
||||
"Permission": serialize.map(permission, lambda e: e),
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RoleInstance(
|
||||
self._version, payload, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self, friendly_name: str, type: "RoleInstance.RoleType", permission: List[str]
|
||||
) -> RoleInstance:
|
||||
"""
|
||||
Asynchronously create the RoleInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the new resource. It can be up to 64 characters long.
|
||||
:param type:
|
||||
:param permission: A permission that you grant to the new role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. The values for this parameter depend on the role's `type`.
|
||||
|
||||
:returns: The created RoleInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"Type": type,
|
||||
"Permission": serialize.map(permission, lambda e: e),
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RoleInstance(
|
||||
self._version, payload, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[RoleInstance]:
|
||||
"""
|
||||
Streams RoleInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[RoleInstance]:
|
||||
"""
|
||||
Asynchronously streams RoleInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[RoleInstance]:
|
||||
"""
|
||||
Lists RoleInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[RoleInstance]:
|
||||
"""
|
||||
Asynchronously lists RoleInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> RolePage:
|
||||
"""
|
||||
Retrieve a single page of RoleInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of RoleInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return RolePage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> RolePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of RoleInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of RoleInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return RolePage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> RolePage:
|
||||
"""
|
||||
Retrieve a specific page of RoleInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of RoleInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return RolePage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> RolePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of RoleInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of RoleInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return RolePage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> RoleContext:
|
||||
"""
|
||||
Constructs a RoleContext
|
||||
|
||||
:param sid: The SID of the Role resource to update.
|
||||
"""
|
||||
return RoleContext(
|
||||
self._version, chat_service_sid=self._solution["chat_service_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> RoleContext:
|
||||
"""
|
||||
Constructs a RoleContext
|
||||
|
||||
:param sid: The SID of the Role resource to update.
|
||||
"""
|
||||
return RoleContext(
|
||||
self._version, chat_service_sid=self._solution["chat_service_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.RoleList>"
|
||||
+763
@@ -0,0 +1,763 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
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.page import Page
|
||||
from twilio.rest.conversations.v1.service.user.user_conversation import (
|
||||
UserConversationList,
|
||||
)
|
||||
|
||||
|
||||
class UserInstance(InstanceResource):
|
||||
class WebhookEnabledType(object):
|
||||
TRUE = "true"
|
||||
FALSE = "false"
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that we created to identify the User resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the User resource.
|
||||
:ivar chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the User resource is associated with.
|
||||
:ivar role_sid: The SID of a service-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) assigned to the user.
|
||||
:ivar identity: The application-defined string that uniquely identifies the resource's User within the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource). This value is often a username or an email address, and is case-sensitive.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar attributes: The JSON Object string that stores application-specific data. If attributes have not been set, `{}` is returned.
|
||||
:ivar is_online: Whether the User is actively connected to this Conversations Service and online. This value is only returned by Fetch actions that return a single resource and `null` is always returned by a Read action. This value is `null` if the Service's `reachability_enabled` is `false`, if the User has never been online for this Conversations Service, even if the Service's `reachability_enabled` is `true`.
|
||||
:ivar is_notifiable: Whether the User has a potentially valid Push Notification registration (APN or GCM) for this Conversations Service. If at least one registration exists, `true`; otherwise `false`. This value is only returned by Fetch actions that return a single resource and `null` is always returned by a Read action. This value is `null` if the Service's `reachability_enabled` is `false`, and if the User has never had a notification registration, even if the Service's `reachability_enabled` is `true`.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar url: An absolute API resource URL for this user.
|
||||
:ivar links:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
chat_service_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.chat_service_sid: Optional[str] = payload.get("chat_service_sid")
|
||||
self.role_sid: Optional[str] = payload.get("role_sid")
|
||||
self.identity: Optional[str] = payload.get("identity")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.attributes: Optional[str] = payload.get("attributes")
|
||||
self.is_online: Optional[bool] = payload.get("is_online")
|
||||
self.is_notifiable: Optional[bool] = payload.get("is_notifiable")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[UserContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "UserContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: UserContext for this UserInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = UserContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"UserInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Deletes the UserInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
)
|
||||
|
||||
async def delete_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"UserInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the UserInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
)
|
||||
|
||||
def fetch(self) -> "UserInstance":
|
||||
"""
|
||||
Fetch the UserInstance
|
||||
|
||||
|
||||
:returns: The fetched UserInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "UserInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the UserInstance
|
||||
|
||||
|
||||
:returns: The fetched UserInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"UserInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
) -> "UserInstance":
|
||||
"""
|
||||
Update the UserInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param friendly_name: The string that you assigned to describe the resource.
|
||||
:param attributes: The JSON Object string that stores application-specific data. If attributes have not been set, `{}` is returned.
|
||||
:param role_sid: The SID of a service-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the user.
|
||||
|
||||
:returns: The updated UserInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
friendly_name=friendly_name,
|
||||
attributes=attributes,
|
||||
role_sid=role_sid,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"UserInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
) -> "UserInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the UserInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param friendly_name: The string that you assigned to describe the resource.
|
||||
:param attributes: The JSON Object string that stores application-specific data. If attributes have not been set, `{}` is returned.
|
||||
:param role_sid: The SID of a service-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the user.
|
||||
|
||||
:returns: The updated UserInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
friendly_name=friendly_name,
|
||||
attributes=attributes,
|
||||
role_sid=role_sid,
|
||||
)
|
||||
|
||||
@property
|
||||
def user_conversations(self) -> UserConversationList:
|
||||
"""
|
||||
Access the user_conversations
|
||||
"""
|
||||
return self._proxy.user_conversations
|
||||
|
||||
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 "<Twilio.Conversations.V1.UserInstance {}>".format(context)
|
||||
|
||||
|
||||
class UserContext(InstanceContext):
|
||||
def __init__(self, version: Version, chat_service_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the UserContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the User resource is associated with.
|
||||
:param sid: The SID of the User resource to update. This value can be either the `sid` or the `identity` of the User resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Services/{chat_service_sid}/Users/{sid}".format(**self._solution)
|
||||
|
||||
self._user_conversations: Optional[UserConversationList] = None
|
||||
|
||||
def delete(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"UserInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Deletes the UserInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
return self._version.delete(method="DELETE", uri=self._uri, headers=headers)
|
||||
|
||||
async def delete_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"UserInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the UserInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
return await self._version.delete_async(
|
||||
method="DELETE", uri=self._uri, headers=headers
|
||||
)
|
||||
|
||||
def fetch(self) -> UserInstance:
|
||||
"""
|
||||
Fetch the UserInstance
|
||||
|
||||
|
||||
:returns: The fetched UserInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return UserInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> UserInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the UserInstance
|
||||
|
||||
|
||||
:returns: The fetched UserInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return UserInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"UserInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
) -> UserInstance:
|
||||
"""
|
||||
Update the UserInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param friendly_name: The string that you assigned to describe the resource.
|
||||
:param attributes: The JSON Object string that stores application-specific data. If attributes have not been set, `{}` is returned.
|
||||
:param role_sid: The SID of a service-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the user.
|
||||
|
||||
:returns: The updated UserInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"Attributes": attributes,
|
||||
"RoleSid": role_sid,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return UserInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"UserInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
) -> UserInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the UserInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param friendly_name: The string that you assigned to describe the resource.
|
||||
:param attributes: The JSON Object string that stores application-specific data. If attributes have not been set, `{}` is returned.
|
||||
:param role_sid: The SID of a service-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the user.
|
||||
|
||||
:returns: The updated UserInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"Attributes": attributes,
|
||||
"RoleSid": role_sid,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return UserInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
@property
|
||||
def user_conversations(self) -> UserConversationList:
|
||||
"""
|
||||
Access the user_conversations
|
||||
"""
|
||||
if self._user_conversations is None:
|
||||
self._user_conversations = UserConversationList(
|
||||
self._version,
|
||||
self._solution["chat_service_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._user_conversations
|
||||
|
||||
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 "<Twilio.Conversations.V1.UserContext {}>".format(context)
|
||||
|
||||
|
||||
class UserPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> UserInstance:
|
||||
"""
|
||||
Build an instance of UserInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return UserInstance(
|
||||
self._version, payload, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.UserPage>"
|
||||
|
||||
|
||||
class UserList(ListResource):
|
||||
def __init__(self, version: Version, chat_service_sid: str):
|
||||
"""
|
||||
Initialize the UserList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) to read the User resources from.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
}
|
||||
self._uri = "/Services/{chat_service_sid}/Users".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self,
|
||||
identity: str,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"UserInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
) -> UserInstance:
|
||||
"""
|
||||
Create the UserInstance
|
||||
|
||||
:param identity: The application-defined string that uniquely identifies the resource's User within the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource). This value is often a username or an email address, and is case-sensitive.
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param friendly_name: The string that you assigned to describe the resource.
|
||||
:param attributes: The JSON Object string that stores application-specific data. If attributes have not been set, `{}` is returned.
|
||||
:param role_sid: The SID of a service-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the user.
|
||||
|
||||
:returns: The created UserInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Identity": identity,
|
||||
"FriendlyName": friendly_name,
|
||||
"Attributes": attributes,
|
||||
"RoleSid": role_sid,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
payload = self._version.create(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return UserInstance(
|
||||
self._version, payload, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
identity: str,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"UserInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
) -> UserInstance:
|
||||
"""
|
||||
Asynchronously create the UserInstance
|
||||
|
||||
:param identity: The application-defined string that uniquely identifies the resource's User within the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource). This value is often a username or an email address, and is case-sensitive.
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param friendly_name: The string that you assigned to describe the resource.
|
||||
:param attributes: The JSON Object string that stores application-specific data. If attributes have not been set, `{}` is returned.
|
||||
:param role_sid: The SID of a service-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the user.
|
||||
|
||||
:returns: The created UserInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Identity": identity,
|
||||
"FriendlyName": friendly_name,
|
||||
"Attributes": attributes,
|
||||
"RoleSid": role_sid,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
payload = await self._version.create_async(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return UserInstance(
|
||||
self._version, payload, chat_service_sid=self._solution["chat_service_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[UserInstance]:
|
||||
"""
|
||||
Streams UserInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[UserInstance]:
|
||||
"""
|
||||
Asynchronously streams UserInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[UserInstance]:
|
||||
"""
|
||||
Lists UserInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[UserInstance]:
|
||||
"""
|
||||
Asynchronously lists UserInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> UserPage:
|
||||
"""
|
||||
Retrieve a single page of UserInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of UserInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return UserPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> UserPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of UserInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of UserInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return UserPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> UserPage:
|
||||
"""
|
||||
Retrieve a specific page of UserInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of UserInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return UserPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> UserPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of UserInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of UserInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return UserPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> UserContext:
|
||||
"""
|
||||
Constructs a UserContext
|
||||
|
||||
:param sid: The SID of the User resource to update. This value can be either the `sid` or the `identity` of the User resource to update.
|
||||
"""
|
||||
return UserContext(
|
||||
self._version, chat_service_sid=self._solution["chat_service_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> UserContext:
|
||||
"""
|
||||
Constructs a UserContext
|
||||
|
||||
:param sid: The SID of the User resource to update. This value can be either the `sid` or the `identity` of the User resource to update.
|
||||
"""
|
||||
return UserContext(
|
||||
self._version, chat_service_sid=self._solution["chat_service_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.UserList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+657
@@ -0,0 +1,657 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
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.page import Page
|
||||
|
||||
|
||||
class UserConversationInstance(InstanceResource):
|
||||
class NotificationLevel(object):
|
||||
DEFAULT = "default"
|
||||
MUTED = "muted"
|
||||
|
||||
class State(object):
|
||||
INACTIVE = "inactive"
|
||||
ACTIVE = "active"
|
||||
CLOSED = "closed"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this conversation.
|
||||
:ivar chat_service_sid: The unique ID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation belongs to.
|
||||
:ivar conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this User Conversation.
|
||||
:ivar unread_messages_count: The number of unread Messages in the Conversation for the Participant.
|
||||
:ivar last_read_message_index: The index of the last Message in the Conversation that the Participant has read.
|
||||
:ivar participant_sid: The unique ID of the [participant](https://www.twilio.com/docs/conversations/api/conversation-participant-resource) the user conversation belongs to.
|
||||
:ivar user_sid: The unique string that identifies the [User resource](https://www.twilio.com/docs/conversations/api/user-resource).
|
||||
:ivar friendly_name: The human-readable name of this conversation, limited to 256 characters. Optional.
|
||||
:ivar conversation_state:
|
||||
:ivar timers: Timer date values representing state update for this conversation.
|
||||
:ivar attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \"{}\" will be returned.
|
||||
:ivar date_created: The date that this conversation was created, given in ISO 8601 format.
|
||||
:ivar date_updated: The date that this conversation was last updated, given in ISO 8601 format.
|
||||
:ivar created_by: Identity of the creator of this Conversation.
|
||||
:ivar notification_level:
|
||||
:ivar unique_name: An application-defined string that uniquely identifies the Conversation resource. It can be used to address the resource in place of the resource's `conversation_sid` in the URL.
|
||||
:ivar url:
|
||||
:ivar links: Contains absolute URLs to access the [participant](https://www.twilio.com/docs/conversations/api/conversation-participant-resource) and [conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) of this conversation.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
chat_service_sid: str,
|
||||
user_sid: str,
|
||||
conversation_sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.chat_service_sid: Optional[str] = payload.get("chat_service_sid")
|
||||
self.conversation_sid: Optional[str] = payload.get("conversation_sid")
|
||||
self.unread_messages_count: Optional[int] = deserialize.integer(
|
||||
payload.get("unread_messages_count")
|
||||
)
|
||||
self.last_read_message_index: Optional[int] = deserialize.integer(
|
||||
payload.get("last_read_message_index")
|
||||
)
|
||||
self.participant_sid: Optional[str] = payload.get("participant_sid")
|
||||
self.user_sid: Optional[str] = payload.get("user_sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.conversation_state: Optional[
|
||||
"UserConversationInstance.State"
|
||||
] = payload.get("conversation_state")
|
||||
self.timers: Optional[Dict[str, object]] = payload.get("timers")
|
||||
self.attributes: Optional[str] = payload.get("attributes")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.created_by: Optional[str] = payload.get("created_by")
|
||||
self.notification_level: Optional[
|
||||
"UserConversationInstance.NotificationLevel"
|
||||
] = payload.get("notification_level")
|
||||
self.unique_name: Optional[str] = payload.get("unique_name")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"user_sid": user_sid,
|
||||
"conversation_sid": conversation_sid or self.conversation_sid,
|
||||
}
|
||||
self._context: Optional[UserConversationContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "UserConversationContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: UserConversationContext for this UserConversationInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = UserConversationContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
user_sid=self._solution["user_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the UserConversationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the UserConversationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "UserConversationInstance":
|
||||
"""
|
||||
Fetch the UserConversationInstance
|
||||
|
||||
|
||||
:returns: The fetched UserConversationInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "UserConversationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the UserConversationInstance
|
||||
|
||||
|
||||
:returns: The fetched UserConversationInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
notification_level: Union[
|
||||
"UserConversationInstance.NotificationLevel", object
|
||||
] = values.unset,
|
||||
last_read_timestamp: Union[datetime, object] = values.unset,
|
||||
last_read_message_index: Union[int, object] = values.unset,
|
||||
) -> "UserConversationInstance":
|
||||
"""
|
||||
Update the UserConversationInstance
|
||||
|
||||
:param notification_level:
|
||||
:param last_read_timestamp: The date of the last message read in conversation by the user, given in ISO 8601 format.
|
||||
:param last_read_message_index: The index of the last Message in the Conversation that the Participant has read.
|
||||
|
||||
:returns: The updated UserConversationInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
notification_level=notification_level,
|
||||
last_read_timestamp=last_read_timestamp,
|
||||
last_read_message_index=last_read_message_index,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
notification_level: Union[
|
||||
"UserConversationInstance.NotificationLevel", object
|
||||
] = values.unset,
|
||||
last_read_timestamp: Union[datetime, object] = values.unset,
|
||||
last_read_message_index: Union[int, object] = values.unset,
|
||||
) -> "UserConversationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the UserConversationInstance
|
||||
|
||||
:param notification_level:
|
||||
:param last_read_timestamp: The date of the last message read in conversation by the user, given in ISO 8601 format.
|
||||
:param last_read_message_index: The index of the last Message in the Conversation that the Participant has read.
|
||||
|
||||
:returns: The updated UserConversationInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
notification_level=notification_level,
|
||||
last_read_timestamp=last_read_timestamp,
|
||||
last_read_message_index=last_read_message_index,
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.UserConversationInstance {}>".format(context)
|
||||
|
||||
|
||||
class UserConversationContext(InstanceContext):
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
chat_service_sid: str,
|
||||
user_sid: str,
|
||||
conversation_sid: str,
|
||||
):
|
||||
"""
|
||||
Initialize the UserConversationContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Conversation resource is associated with.
|
||||
:param user_sid: The unique SID identifier of the [User resource](https://www.twilio.com/docs/conversations/api/user-resource). This value can be either the `sid` or the `identity` of the User resource.
|
||||
:param conversation_sid: The unique SID identifier of the Conversation. This value can be either the `sid` or the `unique_name` of the [Conversation resource](https://www.twilio.com/docs/conversations/api/conversation-resource).
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"user_sid": user_sid,
|
||||
"conversation_sid": conversation_sid,
|
||||
}
|
||||
self._uri = "/Services/{chat_service_sid}/Users/{user_sid}/Conversations/{conversation_sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the UserConversationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the UserConversationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> UserConversationInstance:
|
||||
"""
|
||||
Fetch the UserConversationInstance
|
||||
|
||||
|
||||
:returns: The fetched UserConversationInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return UserConversationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
user_sid=self._solution["user_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> UserConversationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the UserConversationInstance
|
||||
|
||||
|
||||
:returns: The fetched UserConversationInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return UserConversationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
user_sid=self._solution["user_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
notification_level: Union[
|
||||
"UserConversationInstance.NotificationLevel", object
|
||||
] = values.unset,
|
||||
last_read_timestamp: Union[datetime, object] = values.unset,
|
||||
last_read_message_index: Union[int, object] = values.unset,
|
||||
) -> UserConversationInstance:
|
||||
"""
|
||||
Update the UserConversationInstance
|
||||
|
||||
:param notification_level:
|
||||
:param last_read_timestamp: The date of the last message read in conversation by the user, given in ISO 8601 format.
|
||||
:param last_read_message_index: The index of the last Message in the Conversation that the Participant has read.
|
||||
|
||||
:returns: The updated UserConversationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"NotificationLevel": notification_level,
|
||||
"LastReadTimestamp": serialize.iso8601_datetime(last_read_timestamp),
|
||||
"LastReadMessageIndex": last_read_message_index,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return UserConversationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
user_sid=self._solution["user_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
notification_level: Union[
|
||||
"UserConversationInstance.NotificationLevel", object
|
||||
] = values.unset,
|
||||
last_read_timestamp: Union[datetime, object] = values.unset,
|
||||
last_read_message_index: Union[int, object] = values.unset,
|
||||
) -> UserConversationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the UserConversationInstance
|
||||
|
||||
:param notification_level:
|
||||
:param last_read_timestamp: The date of the last message read in conversation by the user, given in ISO 8601 format.
|
||||
:param last_read_message_index: The index of the last Message in the Conversation that the Participant has read.
|
||||
|
||||
:returns: The updated UserConversationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"NotificationLevel": notification_level,
|
||||
"LastReadTimestamp": serialize.iso8601_datetime(last_read_timestamp),
|
||||
"LastReadMessageIndex": last_read_message_index,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return UserConversationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
user_sid=self._solution["user_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.UserConversationContext {}>".format(context)
|
||||
|
||||
|
||||
class UserConversationPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> UserConversationInstance:
|
||||
"""
|
||||
Build an instance of UserConversationInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return UserConversationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
user_sid=self._solution["user_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.UserConversationPage>"
|
||||
|
||||
|
||||
class UserConversationList(ListResource):
|
||||
def __init__(self, version: Version, chat_service_sid: str, user_sid: str):
|
||||
"""
|
||||
Initialize the UserConversationList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Conversation resource is associated with.
|
||||
:param user_sid: The unique SID identifier of the [User resource](https://www.twilio.com/docs/conversations/api/user-resource). This value can be either the `sid` or the `identity` of the User resource.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"chat_service_sid": chat_service_sid,
|
||||
"user_sid": user_sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Services/{chat_service_sid}/Users/{user_sid}/Conversations".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[UserConversationInstance]:
|
||||
"""
|
||||
Streams UserConversationInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[UserConversationInstance]:
|
||||
"""
|
||||
Asynchronously streams UserConversationInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[UserConversationInstance]:
|
||||
"""
|
||||
Lists UserConversationInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[UserConversationInstance]:
|
||||
"""
|
||||
Asynchronously lists UserConversationInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> UserConversationPage:
|
||||
"""
|
||||
Retrieve a single page of UserConversationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of UserConversationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return UserConversationPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> UserConversationPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of UserConversationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of UserConversationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return UserConversationPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> UserConversationPage:
|
||||
"""
|
||||
Retrieve a specific page of UserConversationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of UserConversationInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return UserConversationPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> UserConversationPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of UserConversationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of UserConversationInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return UserConversationPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, conversation_sid: str) -> UserConversationContext:
|
||||
"""
|
||||
Constructs a UserConversationContext
|
||||
|
||||
:param conversation_sid: The unique SID identifier of the Conversation. This value can be either the `sid` or the `unique_name` of the [Conversation resource](https://www.twilio.com/docs/conversations/api/conversation-resource).
|
||||
"""
|
||||
return UserConversationContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
user_sid=self._solution["user_sid"],
|
||||
conversation_sid=conversation_sid,
|
||||
)
|
||||
|
||||
def __call__(self, conversation_sid: str) -> UserConversationContext:
|
||||
"""
|
||||
Constructs a UserConversationContext
|
||||
|
||||
:param conversation_sid: The unique SID identifier of the Conversation. This value can be either the `sid` or the `unique_name` of the [Conversation resource](https://www.twilio.com/docs/conversations/api/conversation-resource).
|
||||
"""
|
||||
return UserConversationContext(
|
||||
self._version,
|
||||
chat_service_sid=self._solution["chat_service_sid"],
|
||||
user_sid=self._solution["user_sid"],
|
||||
conversation_sid=conversation_sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.UserConversationList>"
|
||||
@@ -0,0 +1,725 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
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.page import Page
|
||||
from twilio.rest.conversations.v1.user.user_conversation import UserConversationList
|
||||
|
||||
|
||||
class UserInstance(InstanceResource):
|
||||
class WebhookEnabledType(object):
|
||||
TRUE = "true"
|
||||
FALSE = "false"
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that we created to identify the User resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the User resource.
|
||||
:ivar chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the User resource is associated with.
|
||||
:ivar role_sid: The SID of a service-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) assigned to the user.
|
||||
:ivar identity: The application-defined string that uniquely identifies the resource's User within the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource). This value is often a username or an email address, and is case-sensitive.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar attributes: The JSON Object string that stores application-specific data. If attributes have not been set, `{}` is returned.
|
||||
:ivar is_online: Whether the User is actively connected to this Conversations Service and online. This value is only returned by Fetch actions that return a single resource and `null` is always returned by a Read action. This value is `null` if the Service's `reachability_enabled` is `false`, if the User has never been online for this Conversations Service, even if the Service's `reachability_enabled` is `true`.
|
||||
:ivar is_notifiable: Whether the User has a potentially valid Push Notification registration (APN or GCM) for this Conversations Service. If at least one registration exists, `true`; otherwise `false`. This value is only returned by Fetch actions that return a single resource and `null` is always returned by a Read action. This value is `null` if the Service's `reachability_enabled` is `false`, and if the User has never had a notification registration, even if the Service's `reachability_enabled` is `true`.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar url: An absolute API resource URL for this user.
|
||||
:ivar links:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.chat_service_sid: Optional[str] = payload.get("chat_service_sid")
|
||||
self.role_sid: Optional[str] = payload.get("role_sid")
|
||||
self.identity: Optional[str] = payload.get("identity")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.attributes: Optional[str] = payload.get("attributes")
|
||||
self.is_online: Optional[bool] = payload.get("is_online")
|
||||
self.is_notifiable: Optional[bool] = payload.get("is_notifiable")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
|
||||
self._solution = {
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[UserContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "UserContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: UserContext for this UserInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = UserContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"UserInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Deletes the UserInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
)
|
||||
|
||||
async def delete_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"UserInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the UserInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
)
|
||||
|
||||
def fetch(self) -> "UserInstance":
|
||||
"""
|
||||
Fetch the UserInstance
|
||||
|
||||
|
||||
:returns: The fetched UserInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "UserInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the UserInstance
|
||||
|
||||
|
||||
:returns: The fetched UserInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"UserInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
) -> "UserInstance":
|
||||
"""
|
||||
Update the UserInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param friendly_name: The string that you assigned to describe the resource.
|
||||
:param attributes: The JSON Object string that stores application-specific data. If attributes have not been set, `{}` is returned.
|
||||
:param role_sid: The SID of a service-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the user.
|
||||
|
||||
:returns: The updated UserInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
friendly_name=friendly_name,
|
||||
attributes=attributes,
|
||||
role_sid=role_sid,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"UserInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
) -> "UserInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the UserInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param friendly_name: The string that you assigned to describe the resource.
|
||||
:param attributes: The JSON Object string that stores application-specific data. If attributes have not been set, `{}` is returned.
|
||||
:param role_sid: The SID of a service-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the user.
|
||||
|
||||
:returns: The updated UserInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
x_twilio_webhook_enabled=x_twilio_webhook_enabled,
|
||||
friendly_name=friendly_name,
|
||||
attributes=attributes,
|
||||
role_sid=role_sid,
|
||||
)
|
||||
|
||||
@property
|
||||
def user_conversations(self) -> UserConversationList:
|
||||
"""
|
||||
Access the user_conversations
|
||||
"""
|
||||
return self._proxy.user_conversations
|
||||
|
||||
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 "<Twilio.Conversations.V1.UserInstance {}>".format(context)
|
||||
|
||||
|
||||
class UserContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the UserContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: The SID of the User resource to update. This value can be either the `sid` or the `identity` of the User resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Users/{sid}".format(**self._solution)
|
||||
|
||||
self._user_conversations: Optional[UserConversationList] = None
|
||||
|
||||
def delete(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"UserInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Deletes the UserInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
return self._version.delete(method="DELETE", uri=self._uri, headers=headers)
|
||||
|
||||
async def delete_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"UserInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the UserInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
return await self._version.delete_async(
|
||||
method="DELETE", uri=self._uri, headers=headers
|
||||
)
|
||||
|
||||
def fetch(self) -> UserInstance:
|
||||
"""
|
||||
Fetch the UserInstance
|
||||
|
||||
|
||||
:returns: The fetched UserInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return UserInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> UserInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the UserInstance
|
||||
|
||||
|
||||
:returns: The fetched UserInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return UserInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"UserInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
) -> UserInstance:
|
||||
"""
|
||||
Update the UserInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param friendly_name: The string that you assigned to describe the resource.
|
||||
:param attributes: The JSON Object string that stores application-specific data. If attributes have not been set, `{}` is returned.
|
||||
:param role_sid: The SID of a service-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the user.
|
||||
|
||||
:returns: The updated UserInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"Attributes": attributes,
|
||||
"RoleSid": role_sid,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return UserInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"UserInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
) -> UserInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the UserInstance
|
||||
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param friendly_name: The string that you assigned to describe the resource.
|
||||
:param attributes: The JSON Object string that stores application-specific data. If attributes have not been set, `{}` is returned.
|
||||
:param role_sid: The SID of a service-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the user.
|
||||
|
||||
:returns: The updated UserInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"Attributes": attributes,
|
||||
"RoleSid": role_sid,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return UserInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
@property
|
||||
def user_conversations(self) -> UserConversationList:
|
||||
"""
|
||||
Access the user_conversations
|
||||
"""
|
||||
if self._user_conversations is None:
|
||||
self._user_conversations = UserConversationList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._user_conversations
|
||||
|
||||
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 "<Twilio.Conversations.V1.UserContext {}>".format(context)
|
||||
|
||||
|
||||
class UserPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> UserInstance:
|
||||
"""
|
||||
Build an instance of UserInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return UserInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.UserPage>"
|
||||
|
||||
|
||||
class UserList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the UserList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/Users"
|
||||
|
||||
def create(
|
||||
self,
|
||||
identity: str,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"UserInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
) -> UserInstance:
|
||||
"""
|
||||
Create the UserInstance
|
||||
|
||||
:param identity: The application-defined string that uniquely identifies the resource's User within the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource). This value is often a username or an email address, and is case-sensitive.
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param friendly_name: The string that you assigned to describe the resource.
|
||||
:param attributes: The JSON Object string that stores application-specific data. If attributes have not been set, `{}` is returned.
|
||||
:param role_sid: The SID of a service-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the user.
|
||||
|
||||
:returns: The created UserInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Identity": identity,
|
||||
"FriendlyName": friendly_name,
|
||||
"Attributes": attributes,
|
||||
"RoleSid": role_sid,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
payload = self._version.create(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return UserInstance(self._version, payload)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
identity: str,
|
||||
x_twilio_webhook_enabled: Union[
|
||||
"UserInstance.WebhookEnabledType", object
|
||||
] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
role_sid: Union[str, object] = values.unset,
|
||||
) -> UserInstance:
|
||||
"""
|
||||
Asynchronously create the UserInstance
|
||||
|
||||
:param identity: The application-defined string that uniquely identifies the resource's User within the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource). This value is often a username or an email address, and is case-sensitive.
|
||||
:param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
|
||||
:param friendly_name: The string that you assigned to describe the resource.
|
||||
:param attributes: The JSON Object string that stores application-specific data. If attributes have not been set, `{}` is returned.
|
||||
:param role_sid: The SID of a service-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the user.
|
||||
|
||||
:returns: The created UserInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Identity": identity,
|
||||
"FriendlyName": friendly_name,
|
||||
"Attributes": attributes,
|
||||
"RoleSid": role_sid,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled,
|
||||
}
|
||||
)
|
||||
payload = await self._version.create_async(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return UserInstance(self._version, payload)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[UserInstance]:
|
||||
"""
|
||||
Streams UserInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[UserInstance]:
|
||||
"""
|
||||
Asynchronously streams UserInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[UserInstance]:
|
||||
"""
|
||||
Lists UserInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[UserInstance]:
|
||||
"""
|
||||
Asynchronously lists UserInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> UserPage:
|
||||
"""
|
||||
Retrieve a single page of UserInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of UserInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return UserPage(self._version, response)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> UserPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of UserInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of UserInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return UserPage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> UserPage:
|
||||
"""
|
||||
Retrieve a specific page of UserInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of UserInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return UserPage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> UserPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of UserInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of UserInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return UserPage(self._version, response)
|
||||
|
||||
def get(self, sid: str) -> UserContext:
|
||||
"""
|
||||
Constructs a UserContext
|
||||
|
||||
:param sid: The SID of the User resource to update. This value can be either the `sid` or the `identity` of the User resource to update.
|
||||
"""
|
||||
return UserContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> UserContext:
|
||||
"""
|
||||
Constructs a UserContext
|
||||
|
||||
:param sid: The SID of the User resource to update. This value can be either the `sid` or the `identity` of the User resource to update.
|
||||
"""
|
||||
return UserContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.UserList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+631
@@ -0,0 +1,631 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Conversations
|
||||
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 datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
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.page import Page
|
||||
|
||||
|
||||
class UserConversationInstance(InstanceResource):
|
||||
class NotificationLevel(object):
|
||||
DEFAULT = "default"
|
||||
MUTED = "muted"
|
||||
|
||||
class State(object):
|
||||
INACTIVE = "inactive"
|
||||
ACTIVE = "active"
|
||||
CLOSED = "closed"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this conversation.
|
||||
:ivar chat_service_sid: The unique ID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation belongs to.
|
||||
:ivar conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this User Conversation.
|
||||
:ivar unread_messages_count: The number of unread Messages in the Conversation for the Participant.
|
||||
:ivar last_read_message_index: The index of the last Message in the Conversation that the Participant has read.
|
||||
:ivar participant_sid: The unique ID of the [participant](https://www.twilio.com/docs/conversations/api/conversation-participant-resource) the user conversation belongs to.
|
||||
:ivar user_sid: The unique string that identifies the [User resource](https://www.twilio.com/docs/conversations/api/user-resource).
|
||||
:ivar friendly_name: The human-readable name of this conversation, limited to 256 characters. Optional.
|
||||
:ivar conversation_state:
|
||||
:ivar timers: Timer date values representing state update for this conversation.
|
||||
:ivar attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \"{}\" will be returned.
|
||||
:ivar date_created: The date that this conversation was created, given in ISO 8601 format.
|
||||
:ivar date_updated: The date that this conversation was last updated, given in ISO 8601 format.
|
||||
:ivar created_by: Identity of the creator of this Conversation.
|
||||
:ivar notification_level:
|
||||
:ivar unique_name: An application-defined string that uniquely identifies the Conversation resource. It can be used to address the resource in place of the resource's `conversation_sid` in the URL.
|
||||
:ivar url:
|
||||
:ivar links: Contains absolute URLs to access the [participant](https://www.twilio.com/docs/conversations/api/conversation-participant-resource) and [conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) of this conversation.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
user_sid: str,
|
||||
conversation_sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.chat_service_sid: Optional[str] = payload.get("chat_service_sid")
|
||||
self.conversation_sid: Optional[str] = payload.get("conversation_sid")
|
||||
self.unread_messages_count: Optional[int] = deserialize.integer(
|
||||
payload.get("unread_messages_count")
|
||||
)
|
||||
self.last_read_message_index: Optional[int] = deserialize.integer(
|
||||
payload.get("last_read_message_index")
|
||||
)
|
||||
self.participant_sid: Optional[str] = payload.get("participant_sid")
|
||||
self.user_sid: Optional[str] = payload.get("user_sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.conversation_state: Optional[
|
||||
"UserConversationInstance.State"
|
||||
] = payload.get("conversation_state")
|
||||
self.timers: Optional[Dict[str, object]] = payload.get("timers")
|
||||
self.attributes: Optional[str] = payload.get("attributes")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.created_by: Optional[str] = payload.get("created_by")
|
||||
self.notification_level: Optional[
|
||||
"UserConversationInstance.NotificationLevel"
|
||||
] = payload.get("notification_level")
|
||||
self.unique_name: Optional[str] = payload.get("unique_name")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
|
||||
self._solution = {
|
||||
"user_sid": user_sid,
|
||||
"conversation_sid": conversation_sid or self.conversation_sid,
|
||||
}
|
||||
self._context: Optional[UserConversationContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "UserConversationContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: UserConversationContext for this UserConversationInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = UserConversationContext(
|
||||
self._version,
|
||||
user_sid=self._solution["user_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the UserConversationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the UserConversationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "UserConversationInstance":
|
||||
"""
|
||||
Fetch the UserConversationInstance
|
||||
|
||||
|
||||
:returns: The fetched UserConversationInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "UserConversationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the UserConversationInstance
|
||||
|
||||
|
||||
:returns: The fetched UserConversationInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
notification_level: Union[
|
||||
"UserConversationInstance.NotificationLevel", object
|
||||
] = values.unset,
|
||||
last_read_timestamp: Union[datetime, object] = values.unset,
|
||||
last_read_message_index: Union[int, object] = values.unset,
|
||||
) -> "UserConversationInstance":
|
||||
"""
|
||||
Update the UserConversationInstance
|
||||
|
||||
:param notification_level:
|
||||
:param last_read_timestamp: The date of the last message read in conversation by the user, given in ISO 8601 format.
|
||||
:param last_read_message_index: The index of the last Message in the Conversation that the Participant has read.
|
||||
|
||||
:returns: The updated UserConversationInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
notification_level=notification_level,
|
||||
last_read_timestamp=last_read_timestamp,
|
||||
last_read_message_index=last_read_message_index,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
notification_level: Union[
|
||||
"UserConversationInstance.NotificationLevel", object
|
||||
] = values.unset,
|
||||
last_read_timestamp: Union[datetime, object] = values.unset,
|
||||
last_read_message_index: Union[int, object] = values.unset,
|
||||
) -> "UserConversationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the UserConversationInstance
|
||||
|
||||
:param notification_level:
|
||||
:param last_read_timestamp: The date of the last message read in conversation by the user, given in ISO 8601 format.
|
||||
:param last_read_message_index: The index of the last Message in the Conversation that the Participant has read.
|
||||
|
||||
:returns: The updated UserConversationInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
notification_level=notification_level,
|
||||
last_read_timestamp=last_read_timestamp,
|
||||
last_read_message_index=last_read_message_index,
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.UserConversationInstance {}>".format(context)
|
||||
|
||||
|
||||
class UserConversationContext(InstanceContext):
|
||||
def __init__(self, version: Version, user_sid: str, conversation_sid: str):
|
||||
"""
|
||||
Initialize the UserConversationContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param user_sid: The unique SID identifier of the [User resource](https://www.twilio.com/docs/conversations/api/user-resource). This value can be either the `sid` or the `identity` of the User resource.
|
||||
:param conversation_sid: The unique SID identifier of the Conversation. This value can be either the `sid` or the `unique_name` of the [Conversation resource](https://www.twilio.com/docs/conversations/api/conversation-resource).
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"user_sid": user_sid,
|
||||
"conversation_sid": conversation_sid,
|
||||
}
|
||||
self._uri = "/Users/{user_sid}/Conversations/{conversation_sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the UserConversationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the UserConversationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> UserConversationInstance:
|
||||
"""
|
||||
Fetch the UserConversationInstance
|
||||
|
||||
|
||||
:returns: The fetched UserConversationInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return UserConversationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
user_sid=self._solution["user_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> UserConversationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the UserConversationInstance
|
||||
|
||||
|
||||
:returns: The fetched UserConversationInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return UserConversationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
user_sid=self._solution["user_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
notification_level: Union[
|
||||
"UserConversationInstance.NotificationLevel", object
|
||||
] = values.unset,
|
||||
last_read_timestamp: Union[datetime, object] = values.unset,
|
||||
last_read_message_index: Union[int, object] = values.unset,
|
||||
) -> UserConversationInstance:
|
||||
"""
|
||||
Update the UserConversationInstance
|
||||
|
||||
:param notification_level:
|
||||
:param last_read_timestamp: The date of the last message read in conversation by the user, given in ISO 8601 format.
|
||||
:param last_read_message_index: The index of the last Message in the Conversation that the Participant has read.
|
||||
|
||||
:returns: The updated UserConversationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"NotificationLevel": notification_level,
|
||||
"LastReadTimestamp": serialize.iso8601_datetime(last_read_timestamp),
|
||||
"LastReadMessageIndex": last_read_message_index,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return UserConversationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
user_sid=self._solution["user_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
notification_level: Union[
|
||||
"UserConversationInstance.NotificationLevel", object
|
||||
] = values.unset,
|
||||
last_read_timestamp: Union[datetime, object] = values.unset,
|
||||
last_read_message_index: Union[int, object] = values.unset,
|
||||
) -> UserConversationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the UserConversationInstance
|
||||
|
||||
:param notification_level:
|
||||
:param last_read_timestamp: The date of the last message read in conversation by the user, given in ISO 8601 format.
|
||||
:param last_read_message_index: The index of the last Message in the Conversation that the Participant has read.
|
||||
|
||||
:returns: The updated UserConversationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"NotificationLevel": notification_level,
|
||||
"LastReadTimestamp": serialize.iso8601_datetime(last_read_timestamp),
|
||||
"LastReadMessageIndex": last_read_message_index,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return UserConversationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
user_sid=self._solution["user_sid"],
|
||||
conversation_sid=self._solution["conversation_sid"],
|
||||
)
|
||||
|
||||
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 "<Twilio.Conversations.V1.UserConversationContext {}>".format(context)
|
||||
|
||||
|
||||
class UserConversationPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> UserConversationInstance:
|
||||
"""
|
||||
Build an instance of UserConversationInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return UserConversationInstance(
|
||||
self._version, payload, user_sid=self._solution["user_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.UserConversationPage>"
|
||||
|
||||
|
||||
class UserConversationList(ListResource):
|
||||
def __init__(self, version: Version, user_sid: str):
|
||||
"""
|
||||
Initialize the UserConversationList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param user_sid: The unique SID identifier of the [User resource](https://www.twilio.com/docs/conversations/api/user-resource). This value can be either the `sid` or the `identity` of the User resource.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"user_sid": user_sid,
|
||||
}
|
||||
self._uri = "/Users/{user_sid}/Conversations".format(**self._solution)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[UserConversationInstance]:
|
||||
"""
|
||||
Streams UserConversationInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[UserConversationInstance]:
|
||||
"""
|
||||
Asynchronously streams UserConversationInstance 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[UserConversationInstance]:
|
||||
"""
|
||||
Lists UserConversationInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[UserConversationInstance]:
|
||||
"""
|
||||
Asynchronously lists UserConversationInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
: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(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> UserConversationPage:
|
||||
"""
|
||||
Retrieve a single page of UserConversationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of UserConversationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return UserConversationPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> UserConversationPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of UserConversationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
: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: Page of UserConversationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return UserConversationPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> UserConversationPage:
|
||||
"""
|
||||
Retrieve a specific page of UserConversationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of UserConversationInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return UserConversationPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> UserConversationPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of UserConversationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of UserConversationInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return UserConversationPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, conversation_sid: str) -> UserConversationContext:
|
||||
"""
|
||||
Constructs a UserConversationContext
|
||||
|
||||
:param conversation_sid: The unique SID identifier of the Conversation. This value can be either the `sid` or the `unique_name` of the [Conversation resource](https://www.twilio.com/docs/conversations/api/conversation-resource).
|
||||
"""
|
||||
return UserConversationContext(
|
||||
self._version,
|
||||
user_sid=self._solution["user_sid"],
|
||||
conversation_sid=conversation_sid,
|
||||
)
|
||||
|
||||
def __call__(self, conversation_sid: str) -> UserConversationContext:
|
||||
"""
|
||||
Constructs a UserConversationContext
|
||||
|
||||
:param conversation_sid: The unique SID identifier of the Conversation. This value can be either the `sid` or the `unique_name` of the [Conversation resource](https://www.twilio.com/docs/conversations/api/conversation-resource).
|
||||
"""
|
||||
return UserConversationContext(
|
||||
self._version,
|
||||
user_sid=self._solution["user_sid"],
|
||||
conversation_sid=conversation_sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Conversations.V1.UserConversationList>"
|
||||
Reference in New Issue
Block a user