Initial commit: Email alerts application

This commit is contained in:
Iyeoluwa Akinrinola
2025-07-25 11:31:36 +01:00
commit adfb625ae9
6322 changed files with 2882826 additions and 0 deletions
@@ -0,0 +1,54 @@
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.flex_api.v1 import V1
from twilio.rest.flex_api.v2 import V2
class FlexApiBase(Domain):
def __init__(self, twilio: Client):
"""
Initialize the FlexApi Domain
:returns: Domain for FlexApi
"""
super().__init__(twilio, "https://flex-api.twilio.com")
self._v1: Optional[V1] = None
self._v2: Optional[V2] = None
@property
def v1(self) -> V1:
"""
:returns: Versions v1 of FlexApi
"""
if self._v1 is None:
self._v1 = V1(self)
return self._v1
@property
def v2(self) -> V2:
"""
:returns: Versions v2 of FlexApi
"""
if self._v2 is None:
self._v2 = V2(self)
return self._v2
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi>"
@@ -0,0 +1,185 @@
from warnings import warn
from twilio.rest.flex_api.FlexApiBase import FlexApiBase
from twilio.rest.flex_api.v1.assessments import AssessmentsList
from twilio.rest.flex_api.v1.channel import ChannelList
from twilio.rest.flex_api.v1.configuration import ConfigurationList
from twilio.rest.flex_api.v1.flex_flow import FlexFlowList
from twilio.rest.flex_api.v1.insights_assessments_comment import (
InsightsAssessmentsCommentList,
)
from twilio.rest.flex_api.v1.insights_conversations import InsightsConversationsList
from twilio.rest.flex_api.v1.insights_questionnaires import InsightsQuestionnairesList
from twilio.rest.flex_api.v1.insights_questionnaires_category import (
InsightsQuestionnairesCategoryList,
)
from twilio.rest.flex_api.v1.insights_questionnaires_question import (
InsightsQuestionnairesQuestionList,
)
from twilio.rest.flex_api.v1.insights_segments import InsightsSegmentsList
from twilio.rest.flex_api.v1.insights_session import InsightsSessionList
from twilio.rest.flex_api.v1.insights_settings_answer_sets import (
InsightsSettingsAnswerSetsList,
)
from twilio.rest.flex_api.v1.insights_settings_comment import (
InsightsSettingsCommentList,
)
from twilio.rest.flex_api.v1.insights_user_roles import InsightsUserRolesList
from twilio.rest.flex_api.v1.interaction import InteractionList
from twilio.rest.flex_api.v1.web_channel import WebChannelList
from twilio.rest.flex_api.v2.web_channels import WebChannelsList
class FlexApi(FlexApiBase):
@property
def assessments(self) -> AssessmentsList:
warn(
"assessments is deprecated. Use v1.assessments instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.assessments
@property
def channel(self) -> ChannelList:
warn(
"channel is deprecated. Use v1.channel instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.channel
@property
def configuration(self) -> ConfigurationList:
warn(
"configuration is deprecated. Use v1.configuration instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.configuration
@property
def flex_flow(self) -> FlexFlowList:
warn(
"flex_flow is deprecated. Use v1.flex_flow instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.flex_flow
@property
def insights_assessments_comment(self) -> InsightsAssessmentsCommentList:
warn(
"insights_assessments_comment is deprecated. Use v1.insights_assessments_comment instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.insights_assessments_comment
@property
def insights_conversations(self) -> InsightsConversationsList:
warn(
"insights_conversations is deprecated. Use v1.insights_conversations instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.insights_conversations
@property
def insights_questionnaires(self) -> InsightsQuestionnairesList:
warn(
"insights_questionnaires is deprecated. Use v1.insights_questionnaires instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.insights_questionnaires
@property
def insights_questionnaires_category(self) -> InsightsQuestionnairesCategoryList:
warn(
"insights_questionnaires_category is deprecated. Use v1.insights_questionnaires_category instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.insights_questionnaires_category
@property
def insights_questionnaires_question(self) -> InsightsQuestionnairesQuestionList:
warn(
"insights_questionnaires_question is deprecated. Use v1.insights_questionnaires_question instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.insights_questionnaires_question
@property
def insights_segments(self) -> InsightsSegmentsList:
warn(
"insights_segments is deprecated. Use v1.insights_segments instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.insights_segments
@property
def insights_session(self) -> InsightsSessionList:
warn(
"insights_session is deprecated. Use v1.insights_session instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.insights_session
@property
def insights_settings_answer_sets(self) -> InsightsSettingsAnswerSetsList:
warn(
"insights_settings_answer_sets is deprecated. Use v1.insights_settings_answer_sets instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.insights_settings_answer_sets
@property
def insights_settings_comment(self) -> InsightsSettingsCommentList:
warn(
"insights_settings_comment is deprecated. Use v1.insights_settings_comment instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.insights_settings_comment
@property
def insights_user_roles(self) -> InsightsUserRolesList:
warn(
"insights_user_roles is deprecated. Use v1.insights_user_roles instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.insights_user_roles
@property
def interaction(self) -> InteractionList:
warn(
"interaction is deprecated. Use v1.interaction instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.interaction
@property
def web_channel(self) -> WebChannelList:
warn(
"web_channel is deprecated. Use v1.web_channel instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.web_channel
@property
def web_channels(self) -> WebChannelsList:
warn(
"web_channels is deprecated. Use v2.web_channels instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v2.web_channels
@@ -0,0 +1,184 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
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.flex_api.v1.assessments import AssessmentsList
from twilio.rest.flex_api.v1.channel import ChannelList
from twilio.rest.flex_api.v1.configuration import ConfigurationList
from twilio.rest.flex_api.v1.flex_flow import FlexFlowList
from twilio.rest.flex_api.v1.insights_assessments_comment import (
InsightsAssessmentsCommentList,
)
from twilio.rest.flex_api.v1.insights_conversations import InsightsConversationsList
from twilio.rest.flex_api.v1.insights_questionnaires import InsightsQuestionnairesList
from twilio.rest.flex_api.v1.insights_questionnaires_category import (
InsightsQuestionnairesCategoryList,
)
from twilio.rest.flex_api.v1.insights_questionnaires_question import (
InsightsQuestionnairesQuestionList,
)
from twilio.rest.flex_api.v1.insights_segments import InsightsSegmentsList
from twilio.rest.flex_api.v1.insights_session import InsightsSessionList
from twilio.rest.flex_api.v1.insights_settings_answer_sets import (
InsightsSettingsAnswerSetsList,
)
from twilio.rest.flex_api.v1.insights_settings_comment import (
InsightsSettingsCommentList,
)
from twilio.rest.flex_api.v1.insights_user_roles import InsightsUserRolesList
from twilio.rest.flex_api.v1.interaction import InteractionList
from twilio.rest.flex_api.v1.web_channel import WebChannelList
class V1(Version):
def __init__(self, domain: Domain):
"""
Initialize the V1 version of FlexApi
:param domain: The Twilio.flex_api domain
"""
super().__init__(domain, "v1")
self._assessments: Optional[AssessmentsList] = None
self._channel: Optional[ChannelList] = None
self._configuration: Optional[ConfigurationList] = None
self._flex_flow: Optional[FlexFlowList] = None
self._insights_assessments_comment: Optional[
InsightsAssessmentsCommentList
] = None
self._insights_conversations: Optional[InsightsConversationsList] = None
self._insights_questionnaires: Optional[InsightsQuestionnairesList] = None
self._insights_questionnaires_category: Optional[
InsightsQuestionnairesCategoryList
] = None
self._insights_questionnaires_question: Optional[
InsightsQuestionnairesQuestionList
] = None
self._insights_segments: Optional[InsightsSegmentsList] = None
self._insights_session: Optional[InsightsSessionList] = None
self._insights_settings_answer_sets: Optional[
InsightsSettingsAnswerSetsList
] = None
self._insights_settings_comment: Optional[InsightsSettingsCommentList] = None
self._insights_user_roles: Optional[InsightsUserRolesList] = None
self._interaction: Optional[InteractionList] = None
self._web_channel: Optional[WebChannelList] = None
@property
def assessments(self) -> AssessmentsList:
if self._assessments is None:
self._assessments = AssessmentsList(self)
return self._assessments
@property
def channel(self) -> ChannelList:
if self._channel is None:
self._channel = ChannelList(self)
return self._channel
@property
def configuration(self) -> ConfigurationList:
if self._configuration is None:
self._configuration = ConfigurationList(self)
return self._configuration
@property
def flex_flow(self) -> FlexFlowList:
if self._flex_flow is None:
self._flex_flow = FlexFlowList(self)
return self._flex_flow
@property
def insights_assessments_comment(self) -> InsightsAssessmentsCommentList:
if self._insights_assessments_comment is None:
self._insights_assessments_comment = InsightsAssessmentsCommentList(self)
return self._insights_assessments_comment
@property
def insights_conversations(self) -> InsightsConversationsList:
if self._insights_conversations is None:
self._insights_conversations = InsightsConversationsList(self)
return self._insights_conversations
@property
def insights_questionnaires(self) -> InsightsQuestionnairesList:
if self._insights_questionnaires is None:
self._insights_questionnaires = InsightsQuestionnairesList(self)
return self._insights_questionnaires
@property
def insights_questionnaires_category(self) -> InsightsQuestionnairesCategoryList:
if self._insights_questionnaires_category is None:
self._insights_questionnaires_category = InsightsQuestionnairesCategoryList(
self
)
return self._insights_questionnaires_category
@property
def insights_questionnaires_question(self) -> InsightsQuestionnairesQuestionList:
if self._insights_questionnaires_question is None:
self._insights_questionnaires_question = InsightsQuestionnairesQuestionList(
self
)
return self._insights_questionnaires_question
@property
def insights_segments(self) -> InsightsSegmentsList:
if self._insights_segments is None:
self._insights_segments = InsightsSegmentsList(self)
return self._insights_segments
@property
def insights_session(self) -> InsightsSessionList:
if self._insights_session is None:
self._insights_session = InsightsSessionList(self)
return self._insights_session
@property
def insights_settings_answer_sets(self) -> InsightsSettingsAnswerSetsList:
if self._insights_settings_answer_sets is None:
self._insights_settings_answer_sets = InsightsSettingsAnswerSetsList(self)
return self._insights_settings_answer_sets
@property
def insights_settings_comment(self) -> InsightsSettingsCommentList:
if self._insights_settings_comment is None:
self._insights_settings_comment = InsightsSettingsCommentList(self)
return self._insights_settings_comment
@property
def insights_user_roles(self) -> InsightsUserRolesList:
if self._insights_user_roles is None:
self._insights_user_roles = InsightsUserRolesList(self)
return self._insights_user_roles
@property
def interaction(self) -> InteractionList:
if self._interaction is None:
self._interaction = InteractionList(self)
return self._interaction
@property
def web_channel(self) -> WebChannelList:
if self._web_channel is None:
self._web_channel = WebChannelList(self)
return self._web_channel
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1>"
@@ -0,0 +1,636 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
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, 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 AssessmentsInstance(InstanceResource):
"""
:ivar account_sid: The unique SID identifier of the Account.
:ivar assessment_sid: The SID of the assessment
:ivar offset: Offset of the conversation
:ivar report: The flag indicating if this assessment is part of report
:ivar weight: The weightage given to this comment
:ivar agent_id: The id of the Agent
:ivar segment_id: Segment Id of conversation
:ivar user_name: The name of the user.
:ivar user_email: The email id of the user.
:ivar answer_text: The answer text selected by user
:ivar answer_id: The id of the answer selected by user
:ivar assessment: Assessment Details associated with an assessment
:ivar timestamp:
:ivar url:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
assessment_sid: Optional[str] = None,
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.assessment_sid: Optional[str] = payload.get("assessment_sid")
self.offset: Optional[float] = deserialize.decimal(payload.get("offset"))
self.report: Optional[bool] = payload.get("report")
self.weight: Optional[float] = deserialize.decimal(payload.get("weight"))
self.agent_id: Optional[str] = payload.get("agent_id")
self.segment_id: Optional[str] = payload.get("segment_id")
self.user_name: Optional[str] = payload.get("user_name")
self.user_email: Optional[str] = payload.get("user_email")
self.answer_text: Optional[str] = payload.get("answer_text")
self.answer_id: Optional[str] = payload.get("answer_id")
self.assessment: Optional[Dict[str, object]] = payload.get("assessment")
self.timestamp: Optional[float] = deserialize.decimal(payload.get("timestamp"))
self.url: Optional[str] = payload.get("url")
self._solution = {
"assessment_sid": assessment_sid or self.assessment_sid,
}
self._context: Optional[AssessmentsContext] = None
@property
def _proxy(self) -> "AssessmentsContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: AssessmentsContext for this AssessmentsInstance
"""
if self._context is None:
self._context = AssessmentsContext(
self._version,
assessment_sid=self._solution["assessment_sid"],
)
return self._context
def update(
self,
offset: float,
answer_text: str,
answer_id: str,
authorization: Union[str, object] = values.unset,
) -> "AssessmentsInstance":
"""
Update the AssessmentsInstance
:param offset: The offset of the conversation
:param answer_text: The answer text selected by user
:param answer_id: The id of the answer selected by user
:param authorization: The Authorization HTTP request header
:returns: The updated AssessmentsInstance
"""
return self._proxy.update(
offset=offset,
answer_text=answer_text,
answer_id=answer_id,
authorization=authorization,
)
async def update_async(
self,
offset: float,
answer_text: str,
answer_id: str,
authorization: Union[str, object] = values.unset,
) -> "AssessmentsInstance":
"""
Asynchronous coroutine to update the AssessmentsInstance
:param offset: The offset of the conversation
:param answer_text: The answer text selected by user
:param answer_id: The id of the answer selected by user
:param authorization: The Authorization HTTP request header
:returns: The updated AssessmentsInstance
"""
return await self._proxy.update_async(
offset=offset,
answer_text=answer_text,
answer_id=answer_id,
authorization=authorization,
)
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.FlexApi.V1.AssessmentsInstance {}>".format(context)
class AssessmentsContext(InstanceContext):
def __init__(self, version: Version, assessment_sid: str):
"""
Initialize the AssessmentsContext
:param version: Version that contains the resource
:param assessment_sid: The SID of the assessment to be modified
"""
super().__init__(version)
# Path Solution
self._solution = {
"assessment_sid": assessment_sid,
}
self._uri = "/Insights/QualityManagement/Assessments/{assessment_sid}".format(
**self._solution
)
def update(
self,
offset: float,
answer_text: str,
answer_id: str,
authorization: Union[str, object] = values.unset,
) -> AssessmentsInstance:
"""
Update the AssessmentsInstance
:param offset: The offset of the conversation
:param answer_text: The answer text selected by user
:param answer_id: The id of the answer selected by user
:param authorization: The Authorization HTTP request header
:returns: The updated AssessmentsInstance
"""
data = values.of(
{
"Offset": offset,
"AnswerText": answer_text,
"AnswerId": answer_id,
}
)
headers = values.of(
{
"Authorization": authorization,
}
)
payload = self._version.update(
method="POST", uri=self._uri, data=data, headers=headers
)
return AssessmentsInstance(
self._version, payload, assessment_sid=self._solution["assessment_sid"]
)
async def update_async(
self,
offset: float,
answer_text: str,
answer_id: str,
authorization: Union[str, object] = values.unset,
) -> AssessmentsInstance:
"""
Asynchronous coroutine to update the AssessmentsInstance
:param offset: The offset of the conversation
:param answer_text: The answer text selected by user
:param answer_id: The id of the answer selected by user
:param authorization: The Authorization HTTP request header
:returns: The updated AssessmentsInstance
"""
data = values.of(
{
"Offset": offset,
"AnswerText": answer_text,
"AnswerId": answer_id,
}
)
headers = values.of(
{
"Authorization": authorization,
}
)
payload = await self._version.update_async(
method="POST", uri=self._uri, data=data, headers=headers
)
return AssessmentsInstance(
self._version, payload, assessment_sid=self._solution["assessment_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.FlexApi.V1.AssessmentsContext {}>".format(context)
class AssessmentsPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> AssessmentsInstance:
"""
Build an instance of AssessmentsInstance
:param payload: Payload response from the API
"""
return AssessmentsInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.AssessmentsPage>"
class AssessmentsList(ListResource):
def __init__(self, version: Version):
"""
Initialize the AssessmentsList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Insights/QualityManagement/Assessments"
def create(
self,
category_sid: str,
category_name: str,
segment_id: str,
agent_id: str,
offset: float,
metric_id: str,
metric_name: str,
answer_text: str,
answer_id: str,
questionnaire_sid: str,
authorization: Union[str, object] = values.unset,
) -> AssessmentsInstance:
"""
Create the AssessmentsInstance
:param category_sid: The SID of the category
:param category_name: The name of the category
:param segment_id: Segment Id of the conversation
:param agent_id: The id of the Agent
:param offset: The offset of the conversation.
:param metric_id: The question SID selected for assessment
:param metric_name: The question name of the assessment
:param answer_text: The answer text selected by user
:param answer_id: The id of the answer selected by user
:param questionnaire_sid: Questionnaire SID of the associated question
:param authorization: The Authorization HTTP request header
:returns: The created AssessmentsInstance
"""
data = values.of(
{
"CategorySid": category_sid,
"CategoryName": category_name,
"SegmentId": segment_id,
"AgentId": agent_id,
"Offset": offset,
"MetricId": metric_id,
"MetricName": metric_name,
"AnswerText": answer_text,
"AnswerId": answer_id,
"QuestionnaireSid": questionnaire_sid,
}
)
headers = values.of(
{
"Authorization": authorization,
}
)
payload = self._version.create(
method="POST", uri=self._uri, data=data, headers=headers
)
return AssessmentsInstance(self._version, payload)
async def create_async(
self,
category_sid: str,
category_name: str,
segment_id: str,
agent_id: str,
offset: float,
metric_id: str,
metric_name: str,
answer_text: str,
answer_id: str,
questionnaire_sid: str,
authorization: Union[str, object] = values.unset,
) -> AssessmentsInstance:
"""
Asynchronously create the AssessmentsInstance
:param category_sid: The SID of the category
:param category_name: The name of the category
:param segment_id: Segment Id of the conversation
:param agent_id: The id of the Agent
:param offset: The offset of the conversation.
:param metric_id: The question SID selected for assessment
:param metric_name: The question name of the assessment
:param answer_text: The answer text selected by user
:param answer_id: The id of the answer selected by user
:param questionnaire_sid: Questionnaire SID of the associated question
:param authorization: The Authorization HTTP request header
:returns: The created AssessmentsInstance
"""
data = values.of(
{
"CategorySid": category_sid,
"CategoryName": category_name,
"SegmentId": segment_id,
"AgentId": agent_id,
"Offset": offset,
"MetricId": metric_id,
"MetricName": metric_name,
"AnswerText": answer_text,
"AnswerId": answer_id,
"QuestionnaireSid": questionnaire_sid,
}
)
headers = values.of(
{
"Authorization": authorization,
}
)
payload = await self._version.create_async(
method="POST", uri=self._uri, data=data, headers=headers
)
return AssessmentsInstance(self._version, payload)
def stream(
self,
authorization: Union[str, object] = values.unset,
segment_id: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[AssessmentsInstance]:
"""
Streams AssessmentsInstance 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 authorization: The Authorization HTTP request header
:param str segment_id: The id of the segment.
: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(
authorization=authorization,
segment_id=segment_id,
page_size=limits["page_size"],
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
authorization: Union[str, object] = values.unset,
segment_id: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[AssessmentsInstance]:
"""
Asynchronously streams AssessmentsInstance 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 authorization: The Authorization HTTP request header
:param str segment_id: The id of the segment.
: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(
authorization=authorization,
segment_id=segment_id,
page_size=limits["page_size"],
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
authorization: Union[str, object] = values.unset,
segment_id: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[AssessmentsInstance]:
"""
Lists AssessmentsInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str authorization: The Authorization HTTP request header
:param str segment_id: The id of the segment.
: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(
authorization=authorization,
segment_id=segment_id,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
authorization: Union[str, object] = values.unset,
segment_id: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[AssessmentsInstance]:
"""
Asynchronously lists AssessmentsInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str authorization: The Authorization HTTP request header
:param str segment_id: The id of the segment.
: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(
authorization=authorization,
segment_id=segment_id,
limit=limit,
page_size=page_size,
)
]
def page(
self,
authorization: Union[str, object] = values.unset,
segment_id: 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,
) -> AssessmentsPage:
"""
Retrieve a single page of AssessmentsInstance records from the API.
Request is executed immediately
:param authorization: The Authorization HTTP request header
:param segment_id: The id of the segment.
: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 AssessmentsInstance
"""
data = values.of(
{
"Authorization": authorization,
"SegmentId": segment_id,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return AssessmentsPage(self._version, response)
async def page_async(
self,
authorization: Union[str, object] = values.unset,
segment_id: 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,
) -> AssessmentsPage:
"""
Asynchronously retrieve a single page of AssessmentsInstance records from the API.
Request is executed immediately
:param authorization: The Authorization HTTP request header
:param segment_id: The id of the segment.
: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 AssessmentsInstance
"""
data = values.of(
{
"Authorization": authorization,
"SegmentId": segment_id,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return AssessmentsPage(self._version, response)
def get_page(self, target_url: str) -> AssessmentsPage:
"""
Retrieve a specific page of AssessmentsInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of AssessmentsInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return AssessmentsPage(self._version, response)
async def get_page_async(self, target_url: str) -> AssessmentsPage:
"""
Asynchronously retrieve a specific page of AssessmentsInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of AssessmentsInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return AssessmentsPage(self._version, response)
def get(self, assessment_sid: str) -> AssessmentsContext:
"""
Constructs a AssessmentsContext
:param assessment_sid: The SID of the assessment to be modified
"""
return AssessmentsContext(self._version, assessment_sid=assessment_sid)
def __call__(self, assessment_sid: str) -> AssessmentsContext:
"""
Constructs a AssessmentsContext
:param assessment_sid: The SID of the assessment to be modified
"""
return AssessmentsContext(self._version, assessment_sid=assessment_sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.AssessmentsList>"
@@ -0,0 +1,550 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
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 ChannelInstance(InstanceResource):
"""
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Channel resource and owns this Workflow.
:ivar flex_flow_sid: The SID of the Flex Flow.
:ivar sid: The unique string that we created to identify the Channel resource.
:ivar user_sid: The SID of the chat user.
:ivar task_sid: The SID of the TaskRouter Task. Only valid when integration type is `task`. `null` for integration types `studio` & `external`
:ivar url: The absolute URL of the Flex chat channel resource.
:ivar date_created: The date and time in GMT when the Flex chat channel 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 Flex chat channel was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
"""
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.flex_flow_sid: Optional[str] = payload.get("flex_flow_sid")
self.sid: Optional[str] = payload.get("sid")
self.user_sid: Optional[str] = payload.get("user_sid")
self.task_sid: Optional[str] = payload.get("task_sid")
self.url: Optional[str] = payload.get("url")
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 = {
"sid": sid or self.sid,
}
self._context: Optional[ChannelContext] = None
@property
def _proxy(self) -> "ChannelContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: ChannelContext for this ChannelInstance
"""
if self._context is None:
self._context = ChannelContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the ChannelInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the ChannelInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "ChannelInstance":
"""
Fetch the ChannelInstance
:returns: The fetched ChannelInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "ChannelInstance":
"""
Asynchronous coroutine to fetch the ChannelInstance
:returns: The fetched ChannelInstance
"""
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.FlexApi.V1.ChannelInstance {}>".format(context)
class ChannelContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the ChannelContext
:param version: Version that contains the resource
:param sid: The SID of the Flex chat channel resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/Channels/{sid}".format(**self._solution)
def delete(self) -> bool:
"""
Deletes the ChannelInstance
: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 ChannelInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> ChannelInstance:
"""
Fetch the ChannelInstance
:returns: The fetched ChannelInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return ChannelInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> ChannelInstance:
"""
Asynchronous coroutine to fetch the ChannelInstance
:returns: The fetched ChannelInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return ChannelInstance(
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.FlexApi.V1.ChannelContext {}>".format(context)
class ChannelPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> ChannelInstance:
"""
Build an instance of ChannelInstance
:param payload: Payload response from the API
"""
return ChannelInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.ChannelPage>"
class ChannelList(ListResource):
def __init__(self, version: Version):
"""
Initialize the ChannelList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Channels"
def create(
self,
flex_flow_sid: str,
identity: str,
chat_user_friendly_name: str,
chat_friendly_name: str,
target: Union[str, object] = values.unset,
chat_unique_name: Union[str, object] = values.unset,
pre_engagement_data: Union[str, object] = values.unset,
task_sid: Union[str, object] = values.unset,
task_attributes: Union[str, object] = values.unset,
long_lived: Union[bool, object] = values.unset,
) -> ChannelInstance:
"""
Create the ChannelInstance
:param flex_flow_sid: The SID of the Flex Flow.
:param identity: The `identity` value that uniquely identifies the new resource's chat User.
:param chat_user_friendly_name: The chat participant's friendly name.
:param chat_friendly_name: The chat channel's friendly name.
:param target: The Target Contact Identity, for example the phone number of an SMS.
:param chat_unique_name: The chat channel's unique name.
:param pre_engagement_data: The pre-engagement data.
:param task_sid: The SID of the TaskRouter Task. Only valid when integration type is `task`. `null` for integration types `studio` & `external`
:param task_attributes: The Task attributes to be added for the TaskRouter Task.
:param long_lived: Whether to create the channel as long-lived.
:returns: The created ChannelInstance
"""
data = values.of(
{
"FlexFlowSid": flex_flow_sid,
"Identity": identity,
"ChatUserFriendlyName": chat_user_friendly_name,
"ChatFriendlyName": chat_friendly_name,
"Target": target,
"ChatUniqueName": chat_unique_name,
"PreEngagementData": pre_engagement_data,
"TaskSid": task_sid,
"TaskAttributes": task_attributes,
"LongLived": long_lived,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return ChannelInstance(self._version, payload)
async def create_async(
self,
flex_flow_sid: str,
identity: str,
chat_user_friendly_name: str,
chat_friendly_name: str,
target: Union[str, object] = values.unset,
chat_unique_name: Union[str, object] = values.unset,
pre_engagement_data: Union[str, object] = values.unset,
task_sid: Union[str, object] = values.unset,
task_attributes: Union[str, object] = values.unset,
long_lived: Union[bool, object] = values.unset,
) -> ChannelInstance:
"""
Asynchronously create the ChannelInstance
:param flex_flow_sid: The SID of the Flex Flow.
:param identity: The `identity` value that uniquely identifies the new resource's chat User.
:param chat_user_friendly_name: The chat participant's friendly name.
:param chat_friendly_name: The chat channel's friendly name.
:param target: The Target Contact Identity, for example the phone number of an SMS.
:param chat_unique_name: The chat channel's unique name.
:param pre_engagement_data: The pre-engagement data.
:param task_sid: The SID of the TaskRouter Task. Only valid when integration type is `task`. `null` for integration types `studio` & `external`
:param task_attributes: The Task attributes to be added for the TaskRouter Task.
:param long_lived: Whether to create the channel as long-lived.
:returns: The created ChannelInstance
"""
data = values.of(
{
"FlexFlowSid": flex_flow_sid,
"Identity": identity,
"ChatUserFriendlyName": chat_user_friendly_name,
"ChatFriendlyName": chat_friendly_name,
"Target": target,
"ChatUniqueName": chat_unique_name,
"PreEngagementData": pre_engagement_data,
"TaskSid": task_sid,
"TaskAttributes": task_attributes,
"LongLived": long_lived,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return ChannelInstance(self._version, payload)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[ChannelInstance]:
"""
Streams ChannelInstance 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[ChannelInstance]:
"""
Asynchronously streams ChannelInstance 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[ChannelInstance]:
"""
Lists ChannelInstance 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[ChannelInstance]:
"""
Asynchronously lists ChannelInstance 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,
) -> ChannelPage:
"""
Retrieve a single page of ChannelInstance 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 ChannelInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return ChannelPage(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,
) -> ChannelPage:
"""
Asynchronously retrieve a single page of ChannelInstance 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 ChannelInstance
"""
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 ChannelPage(self._version, response)
def get_page(self, target_url: str) -> ChannelPage:
"""
Retrieve a specific page of ChannelInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of ChannelInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return ChannelPage(self._version, response)
async def get_page_async(self, target_url: str) -> ChannelPage:
"""
Asynchronously retrieve a specific page of ChannelInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of ChannelInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return ChannelPage(self._version, response)
def get(self, sid: str) -> ChannelContext:
"""
Constructs a ChannelContext
:param sid: The SID of the Flex chat channel resource to fetch.
"""
return ChannelContext(self._version, sid=sid)
def __call__(self, sid: str) -> ChannelContext:
"""
Constructs a ChannelContext
:param sid: The SID of the Flex chat channel resource to fetch.
"""
return ChannelContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.ChannelList>"
@@ -0,0 +1,345 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
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
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
class ConfigurationInstance(InstanceResource):
class Status(object):
OK = "ok"
INPROGRESS = "inprogress"
NOTSTARTED = "notstarted"
"""
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Configuration resource.
:ivar date_created: The date and time in GMT when the Configuration 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 Configuration resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar attributes: An object that contains application-specific data.
:ivar status:
:ivar taskrouter_workspace_sid: The SID of the TaskRouter Workspace.
:ivar taskrouter_target_workflow_sid: The SID of the TaskRouter target Workflow.
:ivar taskrouter_target_taskqueue_sid: The SID of the TaskRouter Target TaskQueue.
:ivar taskrouter_taskqueues: The list of TaskRouter TaskQueues.
:ivar taskrouter_skills: The Skill description for TaskRouter workers.
:ivar taskrouter_worker_channels: The TaskRouter default channel capacities and availability for workers.
:ivar taskrouter_worker_attributes: The TaskRouter Worker attributes.
:ivar taskrouter_offline_activity_sid: The TaskRouter SID of the offline activity.
:ivar runtime_domain: The URL where the Flex instance is hosted.
:ivar messaging_service_instance_sid: The SID of the Messaging service instance.
:ivar chat_service_instance_sid: The SID of the chat service this user belongs to.
:ivar flex_service_instance_sid: The SID of the Flex service instance.
:ivar ui_language: The primary language of the Flex UI.
:ivar ui_attributes: The object that describes Flex UI characteristics and settings.
:ivar ui_dependencies: The object that defines the NPM packages and versions to be used in Hosted Flex.
:ivar ui_version: The Pinned UI version.
:ivar service_version: The Flex Service version.
:ivar call_recording_enabled: Whether call recording is enabled.
:ivar call_recording_webhook_url: The call recording webhook URL.
:ivar crm_enabled: Whether CRM is present for Flex.
:ivar crm_type: The CRM type.
:ivar crm_callback_url: The CRM Callback URL.
:ivar crm_fallback_url: The CRM Fallback URL.
:ivar crm_attributes: An object that contains the CRM attributes.
:ivar public_attributes: The list of public attributes, which are visible to unauthenticated clients.
:ivar plugin_service_enabled: Whether the plugin service enabled.
:ivar plugin_service_attributes: The plugin service attributes.
:ivar integrations: A list of objects that contain the configurations for the Integrations supported in this configuration.
:ivar outbound_call_flows: The list of outbound call flows.
:ivar serverless_service_sids: The list of serverless service SIDs.
:ivar queue_stats_configuration: Configurable parameters for Queues Statistics.
:ivar notifications: Configurable parameters for Notifications.
:ivar markdown: Configurable parameters for Markdown.
:ivar url: The absolute URL of the Configuration resource.
:ivar flex_insights_hr: Object with enabled/disabled flag with list of workspaces.
:ivar flex_insights_drilldown: Setting this to true will redirect Flex UI to the URL set in flex_url
:ivar flex_url: URL to redirect to in case drilldown is enabled.
:ivar channel_configs: Settings for different limits for Flex Conversations channels attachments.
:ivar debugger_integration: Configurable parameters for Debugger Integration.
:ivar flex_ui_status_report: Configurable parameters for Flex UI Status report.
:ivar agent_conv_end_methods: Agent conversation end methods.
:ivar citrix_voice_vdi: Citrix voice vdi configuration and settings.
:ivar offline_config: Presence and presence ttl configuration
"""
def __init__(self, version: Version, payload: Dict[str, Any]):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_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.attributes: Optional[Dict[str, object]] = payload.get("attributes")
self.status: Optional["ConfigurationInstance.Status"] = payload.get("status")
self.taskrouter_workspace_sid: Optional[str] = payload.get(
"taskrouter_workspace_sid"
)
self.taskrouter_target_workflow_sid: Optional[str] = payload.get(
"taskrouter_target_workflow_sid"
)
self.taskrouter_target_taskqueue_sid: Optional[str] = payload.get(
"taskrouter_target_taskqueue_sid"
)
self.taskrouter_taskqueues: Optional[List[object]] = payload.get(
"taskrouter_taskqueues"
)
self.taskrouter_skills: Optional[List[object]] = payload.get(
"taskrouter_skills"
)
self.taskrouter_worker_channels: Optional[Dict[str, object]] = payload.get(
"taskrouter_worker_channels"
)
self.taskrouter_worker_attributes: Optional[Dict[str, object]] = payload.get(
"taskrouter_worker_attributes"
)
self.taskrouter_offline_activity_sid: Optional[str] = payload.get(
"taskrouter_offline_activity_sid"
)
self.runtime_domain: Optional[str] = payload.get("runtime_domain")
self.messaging_service_instance_sid: Optional[str] = payload.get(
"messaging_service_instance_sid"
)
self.chat_service_instance_sid: Optional[str] = payload.get(
"chat_service_instance_sid"
)
self.flex_service_instance_sid: Optional[str] = payload.get(
"flex_service_instance_sid"
)
self.ui_language: Optional[str] = payload.get("ui_language")
self.ui_attributes: Optional[Dict[str, object]] = payload.get("ui_attributes")
self.ui_dependencies: Optional[Dict[str, object]] = payload.get(
"ui_dependencies"
)
self.ui_version: Optional[str] = payload.get("ui_version")
self.service_version: Optional[str] = payload.get("service_version")
self.call_recording_enabled: Optional[bool] = payload.get(
"call_recording_enabled"
)
self.call_recording_webhook_url: Optional[str] = payload.get(
"call_recording_webhook_url"
)
self.crm_enabled: Optional[bool] = payload.get("crm_enabled")
self.crm_type: Optional[str] = payload.get("crm_type")
self.crm_callback_url: Optional[str] = payload.get("crm_callback_url")
self.crm_fallback_url: Optional[str] = payload.get("crm_fallback_url")
self.crm_attributes: Optional[Dict[str, object]] = payload.get("crm_attributes")
self.public_attributes: Optional[Dict[str, object]] = payload.get(
"public_attributes"
)
self.plugin_service_enabled: Optional[bool] = payload.get(
"plugin_service_enabled"
)
self.plugin_service_attributes: Optional[Dict[str, object]] = payload.get(
"plugin_service_attributes"
)
self.integrations: Optional[List[object]] = payload.get("integrations")
self.outbound_call_flows: Optional[Dict[str, object]] = payload.get(
"outbound_call_flows"
)
self.serverless_service_sids: Optional[List[str]] = payload.get(
"serverless_service_sids"
)
self.queue_stats_configuration: Optional[Dict[str, object]] = payload.get(
"queue_stats_configuration"
)
self.notifications: Optional[Dict[str, object]] = payload.get("notifications")
self.markdown: Optional[Dict[str, object]] = payload.get("markdown")
self.url: Optional[str] = payload.get("url")
self.flex_insights_hr: Optional[Dict[str, object]] = payload.get(
"flex_insights_hr"
)
self.flex_insights_drilldown: Optional[bool] = payload.get(
"flex_insights_drilldown"
)
self.flex_url: Optional[str] = payload.get("flex_url")
self.channel_configs: Optional[List[object]] = payload.get("channel_configs")
self.debugger_integration: Optional[Dict[str, object]] = payload.get(
"debugger_integration"
)
self.flex_ui_status_report: Optional[Dict[str, object]] = payload.get(
"flex_ui_status_report"
)
self.agent_conv_end_methods: Optional[Dict[str, object]] = payload.get(
"agent_conv_end_methods"
)
self.citrix_voice_vdi: Optional[Dict[str, object]] = payload.get(
"citrix_voice_vdi"
)
self.offline_config: Optional[Dict[str, object]] = payload.get("offline_config")
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, ui_version: Union[str, object] = values.unset
) -> "ConfigurationInstance":
"""
Fetch the ConfigurationInstance
:param ui_version: The Pinned UI version of the Configuration resource to fetch.
:returns: The fetched ConfigurationInstance
"""
return self._proxy.fetch(
ui_version=ui_version,
)
async def fetch_async(
self, ui_version: Union[str, object] = values.unset
) -> "ConfigurationInstance":
"""
Asynchronous coroutine to fetch the ConfigurationInstance
:param ui_version: The Pinned UI version of the Configuration resource to fetch.
:returns: The fetched ConfigurationInstance
"""
return await self._proxy.fetch_async(
ui_version=ui_version,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.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, ui_version: Union[str, object] = values.unset
) -> ConfigurationInstance:
"""
Fetch the ConfigurationInstance
:param ui_version: The Pinned UI version of the Configuration resource to fetch.
:returns: The fetched ConfigurationInstance
"""
data = values.of(
{
"UiVersion": ui_version,
}
)
payload = self._version.fetch(method="GET", uri=self._uri, params=data)
return ConfigurationInstance(
self._version,
payload,
)
async def fetch_async(
self, ui_version: Union[str, object] = values.unset
) -> ConfigurationInstance:
"""
Asynchronous coroutine to fetch the ConfigurationInstance
:param ui_version: The Pinned UI version of the Configuration resource to fetch.
:returns: The fetched ConfigurationInstance
"""
data = values.of(
{
"UiVersion": ui_version,
}
)
payload = await self._version.fetch_async(
method="GET", uri=self._uri, params=data
)
return ConfigurationInstance(
self._version,
payload,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.ConfigurationContext>"
class ConfigurationList(ListResource):
def __init__(self, version: Version):
"""
Initialize the ConfigurationList
:param version: Version that contains the resource
"""
super().__init__(version)
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.FlexApi.V1.ConfigurationList>"
@@ -0,0 +1,922 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
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 FlexFlowInstance(InstanceResource):
class ChannelType(object):
WEB = "web"
SMS = "sms"
FACEBOOK = "facebook"
WHATSAPP = "whatsapp"
LINE = "line"
CUSTOM = "custom"
class IntegrationType(object):
STUDIO = "studio"
EXTERNAL = "external"
TASK = "task"
"""
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Flow resource and owns this Workflow.
: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 sid: The unique string that we created to identify the Flex Flow resource.
:ivar friendly_name: The string that you assigned to describe the resource.
:ivar chat_service_sid: The SID of the chat service.
:ivar channel_type:
:ivar contact_identity: The channel contact's Identity.
:ivar enabled: Whether the Flex Flow is enabled.
:ivar integration_type:
:ivar integration: An object that contains specific parameters for the integration.
:ivar long_lived: When enabled, Flex will keep the chat channel active so that it may be used for subsequent interactions with a contact identity. Defaults to `false`.
:ivar janitor_enabled: When enabled, the Messaging Channel Janitor will remove active Proxy sessions if the associated Task is deleted outside of the Flex UI. Defaults to `false`.
:ivar url: The absolute URL of the Flex Flow resource.
"""
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.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.sid: Optional[str] = payload.get("sid")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.chat_service_sid: Optional[str] = payload.get("chat_service_sid")
self.channel_type: Optional["FlexFlowInstance.ChannelType"] = payload.get(
"channel_type"
)
self.contact_identity: Optional[str] = payload.get("contact_identity")
self.enabled: Optional[bool] = payload.get("enabled")
self.integration_type: Optional[
"FlexFlowInstance.IntegrationType"
] = payload.get("integration_type")
self.integration: Optional[Dict[str, object]] = payload.get("integration")
self.long_lived: Optional[bool] = payload.get("long_lived")
self.janitor_enabled: Optional[bool] = payload.get("janitor_enabled")
self.url: Optional[str] = payload.get("url")
self._solution = {
"sid": sid or self.sid,
}
self._context: Optional[FlexFlowContext] = None
@property
def _proxy(self) -> "FlexFlowContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: FlexFlowContext for this FlexFlowInstance
"""
if self._context is None:
self._context = FlexFlowContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the FlexFlowInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the FlexFlowInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "FlexFlowInstance":
"""
Fetch the FlexFlowInstance
:returns: The fetched FlexFlowInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "FlexFlowInstance":
"""
Asynchronous coroutine to fetch the FlexFlowInstance
:returns: The fetched FlexFlowInstance
"""
return await self._proxy.fetch_async()
def update(
self,
friendly_name: Union[str, object] = values.unset,
chat_service_sid: Union[str, object] = values.unset,
channel_type: Union["FlexFlowInstance.ChannelType", object] = values.unset,
contact_identity: Union[str, object] = values.unset,
enabled: Union[bool, object] = values.unset,
integration_type: Union[
"FlexFlowInstance.IntegrationType", object
] = values.unset,
integration_flow_sid: Union[str, object] = values.unset,
integration_url: Union[str, object] = values.unset,
integration_workspace_sid: Union[str, object] = values.unset,
integration_workflow_sid: Union[str, object] = values.unset,
integration_channel: Union[str, object] = values.unset,
integration_timeout: Union[int, object] = values.unset,
integration_priority: Union[int, object] = values.unset,
integration_creation_on_message: Union[bool, object] = values.unset,
long_lived: Union[bool, object] = values.unset,
janitor_enabled: Union[bool, object] = values.unset,
integration_retry_count: Union[int, object] = values.unset,
) -> "FlexFlowInstance":
"""
Update the FlexFlowInstance
:param friendly_name: A descriptive string that you create to describe the Flex Flow resource.
:param chat_service_sid: The SID of the chat service.
:param channel_type:
:param contact_identity: The channel contact's Identity.
:param enabled: Whether the new Flex Flow is enabled.
:param integration_type:
:param integration_flow_sid: The SID of the Studio Flow. Required when `integrationType` is `studio`.
:param integration_url: The URL of the external webhook. Required when `integrationType` is `external`.
:param integration_workspace_sid: The Workspace SID for a new Task. Required when `integrationType` is `task`.
:param integration_workflow_sid: The Workflow SID for a new Task. Required when `integrationType` is `task`.
:param integration_channel: The Task Channel SID (TCXXXX) or unique name (e.g., `sms`) to use for the Task that will be created. Applicable and required when `integrationType` is `task`. The default value is `default`.
:param integration_timeout: The Task timeout in seconds for a new Task. Default is 86,400 seconds (24 hours). Optional when `integrationType` is `task`, not applicable otherwise.
:param integration_priority: The Task priority of a new Task. The default priority is 0. Optional when `integrationType` is `task`, not applicable otherwise.
:param integration_creation_on_message: In the context of outbound messaging, defines whether to create a Task immediately (and therefore reserve the conversation to current agent), or delay Task creation until the customer sends the first response. Set to false to create immediately, true to delay Task creation. This setting is only applicable for outbound messaging.
:param long_lived: When enabled, Flex will keep the chat channel active so that it may be used for subsequent interactions with a contact identity. Defaults to `false`.
:param janitor_enabled: When enabled, the Messaging Channel Janitor will remove active Proxy sessions if the associated Task is deleted outside of the Flex UI. Defaults to `false`.
:param integration_retry_count: The number of times to retry the Studio Flow or webhook in case of failure. Takes integer values from 0 to 3 with the default being 3. Optional when `integrationType` is `studio` or `external`, not applicable otherwise.
:returns: The updated FlexFlowInstance
"""
return self._proxy.update(
friendly_name=friendly_name,
chat_service_sid=chat_service_sid,
channel_type=channel_type,
contact_identity=contact_identity,
enabled=enabled,
integration_type=integration_type,
integration_flow_sid=integration_flow_sid,
integration_url=integration_url,
integration_workspace_sid=integration_workspace_sid,
integration_workflow_sid=integration_workflow_sid,
integration_channel=integration_channel,
integration_timeout=integration_timeout,
integration_priority=integration_priority,
integration_creation_on_message=integration_creation_on_message,
long_lived=long_lived,
janitor_enabled=janitor_enabled,
integration_retry_count=integration_retry_count,
)
async def update_async(
self,
friendly_name: Union[str, object] = values.unset,
chat_service_sid: Union[str, object] = values.unset,
channel_type: Union["FlexFlowInstance.ChannelType", object] = values.unset,
contact_identity: Union[str, object] = values.unset,
enabled: Union[bool, object] = values.unset,
integration_type: Union[
"FlexFlowInstance.IntegrationType", object
] = values.unset,
integration_flow_sid: Union[str, object] = values.unset,
integration_url: Union[str, object] = values.unset,
integration_workspace_sid: Union[str, object] = values.unset,
integration_workflow_sid: Union[str, object] = values.unset,
integration_channel: Union[str, object] = values.unset,
integration_timeout: Union[int, object] = values.unset,
integration_priority: Union[int, object] = values.unset,
integration_creation_on_message: Union[bool, object] = values.unset,
long_lived: Union[bool, object] = values.unset,
janitor_enabled: Union[bool, object] = values.unset,
integration_retry_count: Union[int, object] = values.unset,
) -> "FlexFlowInstance":
"""
Asynchronous coroutine to update the FlexFlowInstance
:param friendly_name: A descriptive string that you create to describe the Flex Flow resource.
:param chat_service_sid: The SID of the chat service.
:param channel_type:
:param contact_identity: The channel contact's Identity.
:param enabled: Whether the new Flex Flow is enabled.
:param integration_type:
:param integration_flow_sid: The SID of the Studio Flow. Required when `integrationType` is `studio`.
:param integration_url: The URL of the external webhook. Required when `integrationType` is `external`.
:param integration_workspace_sid: The Workspace SID for a new Task. Required when `integrationType` is `task`.
:param integration_workflow_sid: The Workflow SID for a new Task. Required when `integrationType` is `task`.
:param integration_channel: The Task Channel SID (TCXXXX) or unique name (e.g., `sms`) to use for the Task that will be created. Applicable and required when `integrationType` is `task`. The default value is `default`.
:param integration_timeout: The Task timeout in seconds for a new Task. Default is 86,400 seconds (24 hours). Optional when `integrationType` is `task`, not applicable otherwise.
:param integration_priority: The Task priority of a new Task. The default priority is 0. Optional when `integrationType` is `task`, not applicable otherwise.
:param integration_creation_on_message: In the context of outbound messaging, defines whether to create a Task immediately (and therefore reserve the conversation to current agent), or delay Task creation until the customer sends the first response. Set to false to create immediately, true to delay Task creation. This setting is only applicable for outbound messaging.
:param long_lived: When enabled, Flex will keep the chat channel active so that it may be used for subsequent interactions with a contact identity. Defaults to `false`.
:param janitor_enabled: When enabled, the Messaging Channel Janitor will remove active Proxy sessions if the associated Task is deleted outside of the Flex UI. Defaults to `false`.
:param integration_retry_count: The number of times to retry the Studio Flow or webhook in case of failure. Takes integer values from 0 to 3 with the default being 3. Optional when `integrationType` is `studio` or `external`, not applicable otherwise.
:returns: The updated FlexFlowInstance
"""
return await self._proxy.update_async(
friendly_name=friendly_name,
chat_service_sid=chat_service_sid,
channel_type=channel_type,
contact_identity=contact_identity,
enabled=enabled,
integration_type=integration_type,
integration_flow_sid=integration_flow_sid,
integration_url=integration_url,
integration_workspace_sid=integration_workspace_sid,
integration_workflow_sid=integration_workflow_sid,
integration_channel=integration_channel,
integration_timeout=integration_timeout,
integration_priority=integration_priority,
integration_creation_on_message=integration_creation_on_message,
long_lived=long_lived,
janitor_enabled=janitor_enabled,
integration_retry_count=integration_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.FlexApi.V1.FlexFlowInstance {}>".format(context)
class FlexFlowContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the FlexFlowContext
:param version: Version that contains the resource
:param sid: The SID of the Flex Flow resource to update.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/FlexFlows/{sid}".format(**self._solution)
def delete(self) -> bool:
"""
Deletes the FlexFlowInstance
: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 FlexFlowInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> FlexFlowInstance:
"""
Fetch the FlexFlowInstance
:returns: The fetched FlexFlowInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return FlexFlowInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> FlexFlowInstance:
"""
Asynchronous coroutine to fetch the FlexFlowInstance
:returns: The fetched FlexFlowInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return FlexFlowInstance(
self._version,
payload,
sid=self._solution["sid"],
)
def update(
self,
friendly_name: Union[str, object] = values.unset,
chat_service_sid: Union[str, object] = values.unset,
channel_type: Union["FlexFlowInstance.ChannelType", object] = values.unset,
contact_identity: Union[str, object] = values.unset,
enabled: Union[bool, object] = values.unset,
integration_type: Union[
"FlexFlowInstance.IntegrationType", object
] = values.unset,
integration_flow_sid: Union[str, object] = values.unset,
integration_url: Union[str, object] = values.unset,
integration_workspace_sid: Union[str, object] = values.unset,
integration_workflow_sid: Union[str, object] = values.unset,
integration_channel: Union[str, object] = values.unset,
integration_timeout: Union[int, object] = values.unset,
integration_priority: Union[int, object] = values.unset,
integration_creation_on_message: Union[bool, object] = values.unset,
long_lived: Union[bool, object] = values.unset,
janitor_enabled: Union[bool, object] = values.unset,
integration_retry_count: Union[int, object] = values.unset,
) -> FlexFlowInstance:
"""
Update the FlexFlowInstance
:param friendly_name: A descriptive string that you create to describe the Flex Flow resource.
:param chat_service_sid: The SID of the chat service.
:param channel_type:
:param contact_identity: The channel contact's Identity.
:param enabled: Whether the new Flex Flow is enabled.
:param integration_type:
:param integration_flow_sid: The SID of the Studio Flow. Required when `integrationType` is `studio`.
:param integration_url: The URL of the external webhook. Required when `integrationType` is `external`.
:param integration_workspace_sid: The Workspace SID for a new Task. Required when `integrationType` is `task`.
:param integration_workflow_sid: The Workflow SID for a new Task. Required when `integrationType` is `task`.
:param integration_channel: The Task Channel SID (TCXXXX) or unique name (e.g., `sms`) to use for the Task that will be created. Applicable and required when `integrationType` is `task`. The default value is `default`.
:param integration_timeout: The Task timeout in seconds for a new Task. Default is 86,400 seconds (24 hours). Optional when `integrationType` is `task`, not applicable otherwise.
:param integration_priority: The Task priority of a new Task. The default priority is 0. Optional when `integrationType` is `task`, not applicable otherwise.
:param integration_creation_on_message: In the context of outbound messaging, defines whether to create a Task immediately (and therefore reserve the conversation to current agent), or delay Task creation until the customer sends the first response. Set to false to create immediately, true to delay Task creation. This setting is only applicable for outbound messaging.
:param long_lived: When enabled, Flex will keep the chat channel active so that it may be used for subsequent interactions with a contact identity. Defaults to `false`.
:param janitor_enabled: When enabled, the Messaging Channel Janitor will remove active Proxy sessions if the associated Task is deleted outside of the Flex UI. Defaults to `false`.
:param integration_retry_count: The number of times to retry the Studio Flow or webhook in case of failure. Takes integer values from 0 to 3 with the default being 3. Optional when `integrationType` is `studio` or `external`, not applicable otherwise.
:returns: The updated FlexFlowInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"ChatServiceSid": chat_service_sid,
"ChannelType": channel_type,
"ContactIdentity": contact_identity,
"Enabled": enabled,
"IntegrationType": integration_type,
"Integration.FlowSid": integration_flow_sid,
"Integration.Url": integration_url,
"Integration.WorkspaceSid": integration_workspace_sid,
"Integration.WorkflowSid": integration_workflow_sid,
"Integration.Channel": integration_channel,
"Integration.Timeout": integration_timeout,
"Integration.Priority": integration_priority,
"Integration.CreationOnMessage": integration_creation_on_message,
"LongLived": long_lived,
"JanitorEnabled": janitor_enabled,
"Integration.RetryCount": integration_retry_count,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return FlexFlowInstance(self._version, payload, sid=self._solution["sid"])
async def update_async(
self,
friendly_name: Union[str, object] = values.unset,
chat_service_sid: Union[str, object] = values.unset,
channel_type: Union["FlexFlowInstance.ChannelType", object] = values.unset,
contact_identity: Union[str, object] = values.unset,
enabled: Union[bool, object] = values.unset,
integration_type: Union[
"FlexFlowInstance.IntegrationType", object
] = values.unset,
integration_flow_sid: Union[str, object] = values.unset,
integration_url: Union[str, object] = values.unset,
integration_workspace_sid: Union[str, object] = values.unset,
integration_workflow_sid: Union[str, object] = values.unset,
integration_channel: Union[str, object] = values.unset,
integration_timeout: Union[int, object] = values.unset,
integration_priority: Union[int, object] = values.unset,
integration_creation_on_message: Union[bool, object] = values.unset,
long_lived: Union[bool, object] = values.unset,
janitor_enabled: Union[bool, object] = values.unset,
integration_retry_count: Union[int, object] = values.unset,
) -> FlexFlowInstance:
"""
Asynchronous coroutine to update the FlexFlowInstance
:param friendly_name: A descriptive string that you create to describe the Flex Flow resource.
:param chat_service_sid: The SID of the chat service.
:param channel_type:
:param contact_identity: The channel contact's Identity.
:param enabled: Whether the new Flex Flow is enabled.
:param integration_type:
:param integration_flow_sid: The SID of the Studio Flow. Required when `integrationType` is `studio`.
:param integration_url: The URL of the external webhook. Required when `integrationType` is `external`.
:param integration_workspace_sid: The Workspace SID for a new Task. Required when `integrationType` is `task`.
:param integration_workflow_sid: The Workflow SID for a new Task. Required when `integrationType` is `task`.
:param integration_channel: The Task Channel SID (TCXXXX) or unique name (e.g., `sms`) to use for the Task that will be created. Applicable and required when `integrationType` is `task`. The default value is `default`.
:param integration_timeout: The Task timeout in seconds for a new Task. Default is 86,400 seconds (24 hours). Optional when `integrationType` is `task`, not applicable otherwise.
:param integration_priority: The Task priority of a new Task. The default priority is 0. Optional when `integrationType` is `task`, not applicable otherwise.
:param integration_creation_on_message: In the context of outbound messaging, defines whether to create a Task immediately (and therefore reserve the conversation to current agent), or delay Task creation until the customer sends the first response. Set to false to create immediately, true to delay Task creation. This setting is only applicable for outbound messaging.
:param long_lived: When enabled, Flex will keep the chat channel active so that it may be used for subsequent interactions with a contact identity. Defaults to `false`.
:param janitor_enabled: When enabled, the Messaging Channel Janitor will remove active Proxy sessions if the associated Task is deleted outside of the Flex UI. Defaults to `false`.
:param integration_retry_count: The number of times to retry the Studio Flow or webhook in case of failure. Takes integer values from 0 to 3 with the default being 3. Optional when `integrationType` is `studio` or `external`, not applicable otherwise.
:returns: The updated FlexFlowInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"ChatServiceSid": chat_service_sid,
"ChannelType": channel_type,
"ContactIdentity": contact_identity,
"Enabled": enabled,
"IntegrationType": integration_type,
"Integration.FlowSid": integration_flow_sid,
"Integration.Url": integration_url,
"Integration.WorkspaceSid": integration_workspace_sid,
"Integration.WorkflowSid": integration_workflow_sid,
"Integration.Channel": integration_channel,
"Integration.Timeout": integration_timeout,
"Integration.Priority": integration_priority,
"Integration.CreationOnMessage": integration_creation_on_message,
"LongLived": long_lived,
"JanitorEnabled": janitor_enabled,
"Integration.RetryCount": integration_retry_count,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return FlexFlowInstance(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.FlexApi.V1.FlexFlowContext {}>".format(context)
class FlexFlowPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> FlexFlowInstance:
"""
Build an instance of FlexFlowInstance
:param payload: Payload response from the API
"""
return FlexFlowInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.FlexFlowPage>"
class FlexFlowList(ListResource):
def __init__(self, version: Version):
"""
Initialize the FlexFlowList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/FlexFlows"
def create(
self,
friendly_name: str,
chat_service_sid: str,
channel_type: "FlexFlowInstance.ChannelType",
contact_identity: Union[str, object] = values.unset,
enabled: Union[bool, object] = values.unset,
integration_type: Union[
"FlexFlowInstance.IntegrationType", object
] = values.unset,
integration_flow_sid: Union[str, object] = values.unset,
integration_url: Union[str, object] = values.unset,
integration_workspace_sid: Union[str, object] = values.unset,
integration_workflow_sid: Union[str, object] = values.unset,
integration_channel: Union[str, object] = values.unset,
integration_timeout: Union[int, object] = values.unset,
integration_priority: Union[int, object] = values.unset,
integration_creation_on_message: Union[bool, object] = values.unset,
long_lived: Union[bool, object] = values.unset,
janitor_enabled: Union[bool, object] = values.unset,
integration_retry_count: Union[int, object] = values.unset,
) -> FlexFlowInstance:
"""
Create the FlexFlowInstance
:param friendly_name: A descriptive string that you create to describe the Flex Flow resource.
:param chat_service_sid: The SID of the chat service.
:param channel_type:
:param contact_identity: The channel contact's Identity.
:param enabled: Whether the new Flex Flow is enabled.
:param integration_type:
:param integration_flow_sid: The SID of the Studio Flow. Required when `integrationType` is `studio`.
:param integration_url: The URL of the external webhook. Required when `integrationType` is `external`.
:param integration_workspace_sid: The Workspace SID for a new Task. Required when `integrationType` is `task`.
:param integration_workflow_sid: The Workflow SID for a new Task. Required when `integrationType` is `task`.
:param integration_channel: The Task Channel SID (TCXXXX) or unique name (e.g., `sms`) to use for the Task that will be created. Applicable and required when `integrationType` is `task`. The default value is `default`.
:param integration_timeout: The Task timeout in seconds for a new Task. Default is 86,400 seconds (24 hours). Optional when `integrationType` is `task`, not applicable otherwise.
:param integration_priority: The Task priority of a new Task. The default priority is 0. Optional when `integrationType` is `task`, not applicable otherwise.
:param integration_creation_on_message: In the context of outbound messaging, defines whether to create a Task immediately (and therefore reserve the conversation to current agent), or delay Task creation until the customer sends the first response. Set to false to create immediately, true to delay Task creation. This setting is only applicable for outbound messaging.
:param long_lived: When enabled, Flex will keep the chat channel active so that it may be used for subsequent interactions with a contact identity. Defaults to `false`.
:param janitor_enabled: When enabled, the Messaging Channel Janitor will remove active Proxy sessions if the associated Task is deleted outside of the Flex UI. Defaults to `false`.
:param integration_retry_count: The number of times to retry the Studio Flow or webhook in case of failure. Takes integer values from 0 to 3 with the default being 3. Optional when `integrationType` is `studio` or `external`, not applicable otherwise.
:returns: The created FlexFlowInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"ChatServiceSid": chat_service_sid,
"ChannelType": channel_type,
"ContactIdentity": contact_identity,
"Enabled": enabled,
"IntegrationType": integration_type,
"Integration.FlowSid": integration_flow_sid,
"Integration.Url": integration_url,
"Integration.WorkspaceSid": integration_workspace_sid,
"Integration.WorkflowSid": integration_workflow_sid,
"Integration.Channel": integration_channel,
"Integration.Timeout": integration_timeout,
"Integration.Priority": integration_priority,
"Integration.CreationOnMessage": integration_creation_on_message,
"LongLived": long_lived,
"JanitorEnabled": janitor_enabled,
"Integration.RetryCount": integration_retry_count,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return FlexFlowInstance(self._version, payload)
async def create_async(
self,
friendly_name: str,
chat_service_sid: str,
channel_type: "FlexFlowInstance.ChannelType",
contact_identity: Union[str, object] = values.unset,
enabled: Union[bool, object] = values.unset,
integration_type: Union[
"FlexFlowInstance.IntegrationType", object
] = values.unset,
integration_flow_sid: Union[str, object] = values.unset,
integration_url: Union[str, object] = values.unset,
integration_workspace_sid: Union[str, object] = values.unset,
integration_workflow_sid: Union[str, object] = values.unset,
integration_channel: Union[str, object] = values.unset,
integration_timeout: Union[int, object] = values.unset,
integration_priority: Union[int, object] = values.unset,
integration_creation_on_message: Union[bool, object] = values.unset,
long_lived: Union[bool, object] = values.unset,
janitor_enabled: Union[bool, object] = values.unset,
integration_retry_count: Union[int, object] = values.unset,
) -> FlexFlowInstance:
"""
Asynchronously create the FlexFlowInstance
:param friendly_name: A descriptive string that you create to describe the Flex Flow resource.
:param chat_service_sid: The SID of the chat service.
:param channel_type:
:param contact_identity: The channel contact's Identity.
:param enabled: Whether the new Flex Flow is enabled.
:param integration_type:
:param integration_flow_sid: The SID of the Studio Flow. Required when `integrationType` is `studio`.
:param integration_url: The URL of the external webhook. Required when `integrationType` is `external`.
:param integration_workspace_sid: The Workspace SID for a new Task. Required when `integrationType` is `task`.
:param integration_workflow_sid: The Workflow SID for a new Task. Required when `integrationType` is `task`.
:param integration_channel: The Task Channel SID (TCXXXX) or unique name (e.g., `sms`) to use for the Task that will be created. Applicable and required when `integrationType` is `task`. The default value is `default`.
:param integration_timeout: The Task timeout in seconds for a new Task. Default is 86,400 seconds (24 hours). Optional when `integrationType` is `task`, not applicable otherwise.
:param integration_priority: The Task priority of a new Task. The default priority is 0. Optional when `integrationType` is `task`, not applicable otherwise.
:param integration_creation_on_message: In the context of outbound messaging, defines whether to create a Task immediately (and therefore reserve the conversation to current agent), or delay Task creation until the customer sends the first response. Set to false to create immediately, true to delay Task creation. This setting is only applicable for outbound messaging.
:param long_lived: When enabled, Flex will keep the chat channel active so that it may be used for subsequent interactions with a contact identity. Defaults to `false`.
:param janitor_enabled: When enabled, the Messaging Channel Janitor will remove active Proxy sessions if the associated Task is deleted outside of the Flex UI. Defaults to `false`.
:param integration_retry_count: The number of times to retry the Studio Flow or webhook in case of failure. Takes integer values from 0 to 3 with the default being 3. Optional when `integrationType` is `studio` or `external`, not applicable otherwise.
:returns: The created FlexFlowInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"ChatServiceSid": chat_service_sid,
"ChannelType": channel_type,
"ContactIdentity": contact_identity,
"Enabled": enabled,
"IntegrationType": integration_type,
"Integration.FlowSid": integration_flow_sid,
"Integration.Url": integration_url,
"Integration.WorkspaceSid": integration_workspace_sid,
"Integration.WorkflowSid": integration_workflow_sid,
"Integration.Channel": integration_channel,
"Integration.Timeout": integration_timeout,
"Integration.Priority": integration_priority,
"Integration.CreationOnMessage": integration_creation_on_message,
"LongLived": long_lived,
"JanitorEnabled": janitor_enabled,
"Integration.RetryCount": integration_retry_count,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return FlexFlowInstance(self._version, payload)
def stream(
self,
friendly_name: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[FlexFlowInstance]:
"""
Streams FlexFlowInstance 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 friendly_name: The `friendly_name` of the Flex Flow resources to read.
: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(friendly_name=friendly_name, page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
friendly_name: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[FlexFlowInstance]:
"""
Asynchronously streams FlexFlowInstance 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 friendly_name: The `friendly_name` of the Flex Flow resources to read.
: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(
friendly_name=friendly_name, page_size=limits["page_size"]
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
friendly_name: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[FlexFlowInstance]:
"""
Lists FlexFlowInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str friendly_name: The `friendly_name` of the Flex Flow resources to read.
: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(
friendly_name=friendly_name,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
friendly_name: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[FlexFlowInstance]:
"""
Asynchronously lists FlexFlowInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str friendly_name: The `friendly_name` of the Flex Flow resources to read.
: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(
friendly_name=friendly_name,
limit=limit,
page_size=page_size,
)
]
def page(
self,
friendly_name: 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,
) -> FlexFlowPage:
"""
Retrieve a single page of FlexFlowInstance records from the API.
Request is executed immediately
:param friendly_name: The `friendly_name` of the Flex Flow resources to read.
: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 FlexFlowInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return FlexFlowPage(self._version, response)
async def page_async(
self,
friendly_name: 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,
) -> FlexFlowPage:
"""
Asynchronously retrieve a single page of FlexFlowInstance records from the API.
Request is executed immediately
:param friendly_name: The `friendly_name` of the Flex Flow resources to read.
: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 FlexFlowInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return FlexFlowPage(self._version, response)
def get_page(self, target_url: str) -> FlexFlowPage:
"""
Retrieve a specific page of FlexFlowInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of FlexFlowInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return FlexFlowPage(self._version, response)
async def get_page_async(self, target_url: str) -> FlexFlowPage:
"""
Asynchronously retrieve a specific page of FlexFlowInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of FlexFlowInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return FlexFlowPage(self._version, response)
def get(self, sid: str) -> FlexFlowContext:
"""
Constructs a FlexFlowContext
:param sid: The SID of the Flex Flow resource to update.
"""
return FlexFlowContext(self._version, sid=sid)
def __call__(self, sid: str) -> FlexFlowContext:
"""
Constructs a FlexFlowContext
:param sid: The SID of the Flex Flow resource to update.
"""
return FlexFlowContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.FlexFlowList>"
@@ -0,0 +1,435 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
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, 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 InsightsAssessmentsCommentInstance(InstanceResource):
"""
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Insights resource and owns this resource.
:ivar assessment_sid: The SID of the assessment.
:ivar comment: The comment added for assessment.
:ivar offset: The offset
:ivar report: The flag indicating if this assessment is part of report
:ivar weight: The weightage given to this comment
:ivar agent_id: The id of the agent.
:ivar segment_id: The id of the segment.
:ivar user_name: The name of the user.
:ivar user_email: The email id of the user.
:ivar timestamp: The timestamp when the record is inserted
:ivar url:
"""
def __init__(self, version: Version, payload: Dict[str, Any]):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.assessment_sid: Optional[str] = payload.get("assessment_sid")
self.comment: Optional[Dict[str, object]] = payload.get("comment")
self.offset: Optional[float] = deserialize.decimal(payload.get("offset"))
self.report: Optional[bool] = payload.get("report")
self.weight: Optional[float] = deserialize.decimal(payload.get("weight"))
self.agent_id: Optional[str] = payload.get("agent_id")
self.segment_id: Optional[str] = payload.get("segment_id")
self.user_name: Optional[str] = payload.get("user_name")
self.user_email: Optional[str] = payload.get("user_email")
self.timestamp: Optional[float] = deserialize.decimal(payload.get("timestamp"))
self.url: Optional[str] = payload.get("url")
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsAssessmentsCommentInstance>"
class InsightsAssessmentsCommentPage(Page):
def get_instance(
self, payload: Dict[str, Any]
) -> InsightsAssessmentsCommentInstance:
"""
Build an instance of InsightsAssessmentsCommentInstance
:param payload: Payload response from the API
"""
return InsightsAssessmentsCommentInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsAssessmentsCommentPage>"
class InsightsAssessmentsCommentList(ListResource):
def __init__(self, version: Version):
"""
Initialize the InsightsAssessmentsCommentList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Insights/QualityManagement/Assessments/Comments"
def create(
self,
category_id: str,
category_name: str,
comment: str,
segment_id: str,
agent_id: str,
offset: float,
authorization: Union[str, object] = values.unset,
) -> InsightsAssessmentsCommentInstance:
"""
Create the InsightsAssessmentsCommentInstance
:param category_id: The ID of the category
:param category_name: The name of the category
:param comment: The Assessment comment.
:param segment_id: The id of the segment.
:param agent_id: The id of the agent.
:param offset: The offset
:param authorization: The Authorization HTTP request header
:returns: The created InsightsAssessmentsCommentInstance
"""
data = values.of(
{
"CategoryId": category_id,
"CategoryName": category_name,
"Comment": comment,
"SegmentId": segment_id,
"AgentId": agent_id,
"Offset": offset,
}
)
headers = values.of(
{
"Authorization": authorization,
}
)
payload = self._version.create(
method="POST", uri=self._uri, data=data, headers=headers
)
return InsightsAssessmentsCommentInstance(self._version, payload)
async def create_async(
self,
category_id: str,
category_name: str,
comment: str,
segment_id: str,
agent_id: str,
offset: float,
authorization: Union[str, object] = values.unset,
) -> InsightsAssessmentsCommentInstance:
"""
Asynchronously create the InsightsAssessmentsCommentInstance
:param category_id: The ID of the category
:param category_name: The name of the category
:param comment: The Assessment comment.
:param segment_id: The id of the segment.
:param agent_id: The id of the agent.
:param offset: The offset
:param authorization: The Authorization HTTP request header
:returns: The created InsightsAssessmentsCommentInstance
"""
data = values.of(
{
"CategoryId": category_id,
"CategoryName": category_name,
"Comment": comment,
"SegmentId": segment_id,
"AgentId": agent_id,
"Offset": offset,
}
)
headers = values.of(
{
"Authorization": authorization,
}
)
payload = await self._version.create_async(
method="POST", uri=self._uri, data=data, headers=headers
)
return InsightsAssessmentsCommentInstance(self._version, payload)
def stream(
self,
authorization: Union[str, object] = values.unset,
segment_id: Union[str, object] = values.unset,
agent_id: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[InsightsAssessmentsCommentInstance]:
"""
Streams InsightsAssessmentsCommentInstance 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 authorization: The Authorization HTTP request header
:param str segment_id: The id of the segment.
:param str agent_id: The id of the agent.
: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(
authorization=authorization,
segment_id=segment_id,
agent_id=agent_id,
page_size=limits["page_size"],
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
authorization: Union[str, object] = values.unset,
segment_id: Union[str, object] = values.unset,
agent_id: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[InsightsAssessmentsCommentInstance]:
"""
Asynchronously streams InsightsAssessmentsCommentInstance 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 authorization: The Authorization HTTP request header
:param str segment_id: The id of the segment.
:param str agent_id: The id of the agent.
: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(
authorization=authorization,
segment_id=segment_id,
agent_id=agent_id,
page_size=limits["page_size"],
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
authorization: Union[str, object] = values.unset,
segment_id: Union[str, object] = values.unset,
agent_id: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[InsightsAssessmentsCommentInstance]:
"""
Lists InsightsAssessmentsCommentInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str authorization: The Authorization HTTP request header
:param str segment_id: The id of the segment.
:param str agent_id: The id of the agent.
: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(
authorization=authorization,
segment_id=segment_id,
agent_id=agent_id,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
authorization: Union[str, object] = values.unset,
segment_id: Union[str, object] = values.unset,
agent_id: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[InsightsAssessmentsCommentInstance]:
"""
Asynchronously lists InsightsAssessmentsCommentInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str authorization: The Authorization HTTP request header
:param str segment_id: The id of the segment.
:param str agent_id: The id of the agent.
: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(
authorization=authorization,
segment_id=segment_id,
agent_id=agent_id,
limit=limit,
page_size=page_size,
)
]
def page(
self,
authorization: Union[str, object] = values.unset,
segment_id: Union[str, object] = values.unset,
agent_id: 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,
) -> InsightsAssessmentsCommentPage:
"""
Retrieve a single page of InsightsAssessmentsCommentInstance records from the API.
Request is executed immediately
:param authorization: The Authorization HTTP request header
:param segment_id: The id of the segment.
:param agent_id: The id of the agent.
: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 InsightsAssessmentsCommentInstance
"""
data = values.of(
{
"Authorization": authorization,
"SegmentId": segment_id,
"AgentId": agent_id,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return InsightsAssessmentsCommentPage(self._version, response)
async def page_async(
self,
authorization: Union[str, object] = values.unset,
segment_id: Union[str, object] = values.unset,
agent_id: 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,
) -> InsightsAssessmentsCommentPage:
"""
Asynchronously retrieve a single page of InsightsAssessmentsCommentInstance records from the API.
Request is executed immediately
:param authorization: The Authorization HTTP request header
:param segment_id: The id of the segment.
:param agent_id: The id of the agent.
: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 InsightsAssessmentsCommentInstance
"""
data = values.of(
{
"Authorization": authorization,
"SegmentId": segment_id,
"AgentId": agent_id,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return InsightsAssessmentsCommentPage(self._version, response)
def get_page(self, target_url: str) -> InsightsAssessmentsCommentPage:
"""
Retrieve a specific page of InsightsAssessmentsCommentInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InsightsAssessmentsCommentInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return InsightsAssessmentsCommentPage(self._version, response)
async def get_page_async(self, target_url: str) -> InsightsAssessmentsCommentPage:
"""
Asynchronously retrieve a specific page of InsightsAssessmentsCommentInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InsightsAssessmentsCommentInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return InsightsAssessmentsCommentPage(self._version, response)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsAssessmentsCommentList>"
@@ -0,0 +1,313 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
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, 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 InsightsConversationsInstance(InstanceResource):
"""
:ivar account_id: The id of the account.
:ivar conversation_id: The unique id of the conversation
:ivar segment_count: The count of segments for a conversation
:ivar segments: The Segments of a conversation
"""
def __init__(self, version: Version, payload: Dict[str, Any]):
super().__init__(version)
self.account_id: Optional[str] = payload.get("account_id")
self.conversation_id: Optional[str] = payload.get("conversation_id")
self.segment_count: Optional[int] = deserialize.integer(
payload.get("segment_count")
)
self.segments: Optional[List[object]] = payload.get("segments")
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsConversationsInstance>"
class InsightsConversationsPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> InsightsConversationsInstance:
"""
Build an instance of InsightsConversationsInstance
:param payload: Payload response from the API
"""
return InsightsConversationsInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsConversationsPage>"
class InsightsConversationsList(ListResource):
def __init__(self, version: Version):
"""
Initialize the InsightsConversationsList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Insights/Conversations"
def stream(
self,
authorization: Union[str, object] = values.unset,
segment_id: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[InsightsConversationsInstance]:
"""
Streams InsightsConversationsInstance 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 authorization: The Authorization HTTP request header
:param str segment_id: Unique Id of the segment for which conversation details needs to be fetched
: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(
authorization=authorization,
segment_id=segment_id,
page_size=limits["page_size"],
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
authorization: Union[str, object] = values.unset,
segment_id: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[InsightsConversationsInstance]:
"""
Asynchronously streams InsightsConversationsInstance 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 authorization: The Authorization HTTP request header
:param str segment_id: Unique Id of the segment for which conversation details needs to be fetched
: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(
authorization=authorization,
segment_id=segment_id,
page_size=limits["page_size"],
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
authorization: Union[str, object] = values.unset,
segment_id: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[InsightsConversationsInstance]:
"""
Lists InsightsConversationsInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str authorization: The Authorization HTTP request header
:param str segment_id: Unique Id of the segment for which conversation details needs to be fetched
: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(
authorization=authorization,
segment_id=segment_id,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
authorization: Union[str, object] = values.unset,
segment_id: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[InsightsConversationsInstance]:
"""
Asynchronously lists InsightsConversationsInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str authorization: The Authorization HTTP request header
:param str segment_id: Unique Id of the segment for which conversation details needs to be fetched
: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(
authorization=authorization,
segment_id=segment_id,
limit=limit,
page_size=page_size,
)
]
def page(
self,
authorization: Union[str, object] = values.unset,
segment_id: 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,
) -> InsightsConversationsPage:
"""
Retrieve a single page of InsightsConversationsInstance records from the API.
Request is executed immediately
:param authorization: The Authorization HTTP request header
:param segment_id: Unique Id of the segment for which conversation details needs to be fetched
: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 InsightsConversationsInstance
"""
data = values.of(
{
"Authorization": authorization,
"SegmentId": segment_id,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return InsightsConversationsPage(self._version, response)
async def page_async(
self,
authorization: Union[str, object] = values.unset,
segment_id: 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,
) -> InsightsConversationsPage:
"""
Asynchronously retrieve a single page of InsightsConversationsInstance records from the API.
Request is executed immediately
:param authorization: The Authorization HTTP request header
:param segment_id: Unique Id of the segment for which conversation details needs to be fetched
: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 InsightsConversationsInstance
"""
data = values.of(
{
"Authorization": authorization,
"SegmentId": segment_id,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return InsightsConversationsPage(self._version, response)
def get_page(self, target_url: str) -> InsightsConversationsPage:
"""
Retrieve a specific page of InsightsConversationsInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InsightsConversationsInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return InsightsConversationsPage(self._version, response)
async def get_page_async(self, target_url: str) -> InsightsConversationsPage:
"""
Asynchronously retrieve a specific page of InsightsConversationsInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InsightsConversationsInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return InsightsConversationsPage(self._version, response)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsConversationsList>"
@@ -0,0 +1,750 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
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, Iterator, AsyncIterator
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
from twilio.base.page import Page
class InsightsQuestionnairesInstance(InstanceResource):
"""
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Insights resource and owns this resource.
:ivar questionnaire_sid: The sid of this questionnaire
:ivar name: The name of this category.
:ivar description: The description of this questionnaire
:ivar active: The flag to enable or disable questionnaire
:ivar questions: The list of questions with category for a questionnaire
:ivar url:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
questionnaire_sid: Optional[str] = None,
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.questionnaire_sid: Optional[str] = payload.get("questionnaire_sid")
self.name: Optional[str] = payload.get("name")
self.description: Optional[str] = payload.get("description")
self.active: Optional[bool] = payload.get("active")
self.questions: Optional[List[object]] = payload.get("questions")
self.url: Optional[str] = payload.get("url")
self._solution = {
"questionnaire_sid": questionnaire_sid or self.questionnaire_sid,
}
self._context: Optional[InsightsQuestionnairesContext] = None
@property
def _proxy(self) -> "InsightsQuestionnairesContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: InsightsQuestionnairesContext for this InsightsQuestionnairesInstance
"""
if self._context is None:
self._context = InsightsQuestionnairesContext(
self._version,
questionnaire_sid=self._solution["questionnaire_sid"],
)
return self._context
def delete(self, authorization: Union[str, object] = values.unset) -> bool:
"""
Deletes the InsightsQuestionnairesInstance
:param authorization: The Authorization HTTP request header
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete(
authorization=authorization,
)
async def delete_async(
self, authorization: Union[str, object] = values.unset
) -> bool:
"""
Asynchronous coroutine that deletes the InsightsQuestionnairesInstance
:param authorization: The Authorization HTTP request header
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async(
authorization=authorization,
)
def fetch(
self, authorization: Union[str, object] = values.unset
) -> "InsightsQuestionnairesInstance":
"""
Fetch the InsightsQuestionnairesInstance
:param authorization: The Authorization HTTP request header
:returns: The fetched InsightsQuestionnairesInstance
"""
return self._proxy.fetch(
authorization=authorization,
)
async def fetch_async(
self, authorization: Union[str, object] = values.unset
) -> "InsightsQuestionnairesInstance":
"""
Asynchronous coroutine to fetch the InsightsQuestionnairesInstance
:param authorization: The Authorization HTTP request header
:returns: The fetched InsightsQuestionnairesInstance
"""
return await self._proxy.fetch_async(
authorization=authorization,
)
def update(
self,
active: bool,
authorization: Union[str, object] = values.unset,
name: Union[str, object] = values.unset,
description: Union[str, object] = values.unset,
question_sids: Union[List[str], object] = values.unset,
) -> "InsightsQuestionnairesInstance":
"""
Update the InsightsQuestionnairesInstance
:param active: The flag to enable or disable questionnaire
:param authorization: The Authorization HTTP request header
:param name: The name of this questionnaire
:param description: The description of this questionnaire
:param question_sids: The list of questions sids under a questionnaire
:returns: The updated InsightsQuestionnairesInstance
"""
return self._proxy.update(
active=active,
authorization=authorization,
name=name,
description=description,
question_sids=question_sids,
)
async def update_async(
self,
active: bool,
authorization: Union[str, object] = values.unset,
name: Union[str, object] = values.unset,
description: Union[str, object] = values.unset,
question_sids: Union[List[str], object] = values.unset,
) -> "InsightsQuestionnairesInstance":
"""
Asynchronous coroutine to update the InsightsQuestionnairesInstance
:param active: The flag to enable or disable questionnaire
:param authorization: The Authorization HTTP request header
:param name: The name of this questionnaire
:param description: The description of this questionnaire
:param question_sids: The list of questions sids under a questionnaire
:returns: The updated InsightsQuestionnairesInstance
"""
return await self._proxy.update_async(
active=active,
authorization=authorization,
name=name,
description=description,
question_sids=question_sids,
)
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.FlexApi.V1.InsightsQuestionnairesInstance {}>".format(context)
class InsightsQuestionnairesContext(InstanceContext):
def __init__(self, version: Version, questionnaire_sid: str):
"""
Initialize the InsightsQuestionnairesContext
:param version: Version that contains the resource
:param questionnaire_sid: The SID of the questionnaire
"""
super().__init__(version)
# Path Solution
self._solution = {
"questionnaire_sid": questionnaire_sid,
}
self._uri = (
"/Insights/QualityManagement/Questionnaires/{questionnaire_sid}".format(
**self._solution
)
)
def delete(self, authorization: Union[str, object] = values.unset) -> bool:
"""
Deletes the InsightsQuestionnairesInstance
:param authorization: The Authorization HTTP request header
:returns: True if delete succeeds, False otherwise
"""
headers = values.of(
{
"Authorization": authorization,
}
)
return self._version.delete(method="DELETE", uri=self._uri, headers=headers)
async def delete_async(
self, authorization: Union[str, object] = values.unset
) -> bool:
"""
Asynchronous coroutine that deletes the InsightsQuestionnairesInstance
:param authorization: The Authorization HTTP request header
:returns: True if delete succeeds, False otherwise
"""
headers = values.of(
{
"Authorization": authorization,
}
)
return await self._version.delete_async(
method="DELETE", uri=self._uri, headers=headers
)
def fetch(
self, authorization: Union[str, object] = values.unset
) -> InsightsQuestionnairesInstance:
"""
Fetch the InsightsQuestionnairesInstance
:param authorization: The Authorization HTTP request header
:returns: The fetched InsightsQuestionnairesInstance
"""
data = values.of(
{
"Authorization": authorization,
}
)
payload = self._version.fetch(method="GET", uri=self._uri, params=data)
return InsightsQuestionnairesInstance(
self._version,
payload,
questionnaire_sid=self._solution["questionnaire_sid"],
)
async def fetch_async(
self, authorization: Union[str, object] = values.unset
) -> InsightsQuestionnairesInstance:
"""
Asynchronous coroutine to fetch the InsightsQuestionnairesInstance
:param authorization: The Authorization HTTP request header
:returns: The fetched InsightsQuestionnairesInstance
"""
data = values.of(
{
"Authorization": authorization,
}
)
payload = await self._version.fetch_async(
method="GET", uri=self._uri, params=data
)
return InsightsQuestionnairesInstance(
self._version,
payload,
questionnaire_sid=self._solution["questionnaire_sid"],
)
def update(
self,
active: bool,
authorization: Union[str, object] = values.unset,
name: Union[str, object] = values.unset,
description: Union[str, object] = values.unset,
question_sids: Union[List[str], object] = values.unset,
) -> InsightsQuestionnairesInstance:
"""
Update the InsightsQuestionnairesInstance
:param active: The flag to enable or disable questionnaire
:param authorization: The Authorization HTTP request header
:param name: The name of this questionnaire
:param description: The description of this questionnaire
:param question_sids: The list of questions sids under a questionnaire
:returns: The updated InsightsQuestionnairesInstance
"""
data = values.of(
{
"Active": active,
"Name": name,
"Description": description,
"QuestionSids": serialize.map(question_sids, lambda e: e),
}
)
headers = values.of(
{
"Authorization": authorization,
}
)
payload = self._version.update(
method="POST", uri=self._uri, data=data, headers=headers
)
return InsightsQuestionnairesInstance(
self._version,
payload,
questionnaire_sid=self._solution["questionnaire_sid"],
)
async def update_async(
self,
active: bool,
authorization: Union[str, object] = values.unset,
name: Union[str, object] = values.unset,
description: Union[str, object] = values.unset,
question_sids: Union[List[str], object] = values.unset,
) -> InsightsQuestionnairesInstance:
"""
Asynchronous coroutine to update the InsightsQuestionnairesInstance
:param active: The flag to enable or disable questionnaire
:param authorization: The Authorization HTTP request header
:param name: The name of this questionnaire
:param description: The description of this questionnaire
:param question_sids: The list of questions sids under a questionnaire
:returns: The updated InsightsQuestionnairesInstance
"""
data = values.of(
{
"Active": active,
"Name": name,
"Description": description,
"QuestionSids": serialize.map(question_sids, lambda e: e),
}
)
headers = values.of(
{
"Authorization": authorization,
}
)
payload = await self._version.update_async(
method="POST", uri=self._uri, data=data, headers=headers
)
return InsightsQuestionnairesInstance(
self._version,
payload,
questionnaire_sid=self._solution["questionnaire_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.FlexApi.V1.InsightsQuestionnairesContext {}>".format(context)
class InsightsQuestionnairesPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> InsightsQuestionnairesInstance:
"""
Build an instance of InsightsQuestionnairesInstance
:param payload: Payload response from the API
"""
return InsightsQuestionnairesInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsQuestionnairesPage>"
class InsightsQuestionnairesList(ListResource):
def __init__(self, version: Version):
"""
Initialize the InsightsQuestionnairesList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Insights/QualityManagement/Questionnaires"
def create(
self,
name: str,
authorization: Union[str, object] = values.unset,
description: Union[str, object] = values.unset,
active: Union[bool, object] = values.unset,
question_sids: Union[List[str], object] = values.unset,
) -> InsightsQuestionnairesInstance:
"""
Create the InsightsQuestionnairesInstance
:param name: The name of this questionnaire
:param authorization: The Authorization HTTP request header
:param description: The description of this questionnaire
:param active: The flag to enable or disable questionnaire
:param question_sids: The list of questions sids under a questionnaire
:returns: The created InsightsQuestionnairesInstance
"""
data = values.of(
{
"Name": name,
"Description": description,
"Active": active,
"QuestionSids": serialize.map(question_sids, lambda e: e),
}
)
headers = values.of(
{
"Authorization": authorization,
}
)
payload = self._version.create(
method="POST", uri=self._uri, data=data, headers=headers
)
return InsightsQuestionnairesInstance(self._version, payload)
async def create_async(
self,
name: str,
authorization: Union[str, object] = values.unset,
description: Union[str, object] = values.unset,
active: Union[bool, object] = values.unset,
question_sids: Union[List[str], object] = values.unset,
) -> InsightsQuestionnairesInstance:
"""
Asynchronously create the InsightsQuestionnairesInstance
:param name: The name of this questionnaire
:param authorization: The Authorization HTTP request header
:param description: The description of this questionnaire
:param active: The flag to enable or disable questionnaire
:param question_sids: The list of questions sids under a questionnaire
:returns: The created InsightsQuestionnairesInstance
"""
data = values.of(
{
"Name": name,
"Description": description,
"Active": active,
"QuestionSids": serialize.map(question_sids, lambda e: e),
}
)
headers = values.of(
{
"Authorization": authorization,
}
)
payload = await self._version.create_async(
method="POST", uri=self._uri, data=data, headers=headers
)
return InsightsQuestionnairesInstance(self._version, payload)
def stream(
self,
authorization: Union[str, object] = values.unset,
include_inactive: Union[bool, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[InsightsQuestionnairesInstance]:
"""
Streams InsightsQuestionnairesInstance 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 authorization: The Authorization HTTP request header
:param bool include_inactive: Flag indicating whether to include inactive questionnaires or not
: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(
authorization=authorization,
include_inactive=include_inactive,
page_size=limits["page_size"],
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
authorization: Union[str, object] = values.unset,
include_inactive: Union[bool, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[InsightsQuestionnairesInstance]:
"""
Asynchronously streams InsightsQuestionnairesInstance 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 authorization: The Authorization HTTP request header
:param bool include_inactive: Flag indicating whether to include inactive questionnaires or not
: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(
authorization=authorization,
include_inactive=include_inactive,
page_size=limits["page_size"],
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
authorization: Union[str, object] = values.unset,
include_inactive: Union[bool, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[InsightsQuestionnairesInstance]:
"""
Lists InsightsQuestionnairesInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str authorization: The Authorization HTTP request header
:param bool include_inactive: Flag indicating whether to include inactive questionnaires or not
: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(
authorization=authorization,
include_inactive=include_inactive,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
authorization: Union[str, object] = values.unset,
include_inactive: Union[bool, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[InsightsQuestionnairesInstance]:
"""
Asynchronously lists InsightsQuestionnairesInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str authorization: The Authorization HTTP request header
:param bool include_inactive: Flag indicating whether to include inactive questionnaires or not
: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(
authorization=authorization,
include_inactive=include_inactive,
limit=limit,
page_size=page_size,
)
]
def page(
self,
authorization: Union[str, object] = values.unset,
include_inactive: Union[bool, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> InsightsQuestionnairesPage:
"""
Retrieve a single page of InsightsQuestionnairesInstance records from the API.
Request is executed immediately
:param authorization: The Authorization HTTP request header
:param include_inactive: Flag indicating whether to include inactive questionnaires or not
: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 InsightsQuestionnairesInstance
"""
data = values.of(
{
"Authorization": authorization,
"IncludeInactive": include_inactive,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return InsightsQuestionnairesPage(self._version, response)
async def page_async(
self,
authorization: Union[str, object] = values.unset,
include_inactive: Union[bool, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> InsightsQuestionnairesPage:
"""
Asynchronously retrieve a single page of InsightsQuestionnairesInstance records from the API.
Request is executed immediately
:param authorization: The Authorization HTTP request header
:param include_inactive: Flag indicating whether to include inactive questionnaires or not
: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 InsightsQuestionnairesInstance
"""
data = values.of(
{
"Authorization": authorization,
"IncludeInactive": include_inactive,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return InsightsQuestionnairesPage(self._version, response)
def get_page(self, target_url: str) -> InsightsQuestionnairesPage:
"""
Retrieve a specific page of InsightsQuestionnairesInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InsightsQuestionnairesInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return InsightsQuestionnairesPage(self._version, response)
async def get_page_async(self, target_url: str) -> InsightsQuestionnairesPage:
"""
Asynchronously retrieve a specific page of InsightsQuestionnairesInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InsightsQuestionnairesInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return InsightsQuestionnairesPage(self._version, response)
def get(self, questionnaire_sid: str) -> InsightsQuestionnairesContext:
"""
Constructs a InsightsQuestionnairesContext
:param questionnaire_sid: The SID of the questionnaire
"""
return InsightsQuestionnairesContext(
self._version, questionnaire_sid=questionnaire_sid
)
def __call__(self, questionnaire_sid: str) -> InsightsQuestionnairesContext:
"""
Constructs a InsightsQuestionnairesContext
:param questionnaire_sid: The SID of the questionnaire
"""
return InsightsQuestionnairesContext(
self._version, questionnaire_sid=questionnaire_sid
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsQuestionnairesList>"
@@ -0,0 +1,578 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
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, Iterator, AsyncIterator
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.base.page import Page
class InsightsQuestionnairesCategoryInstance(InstanceResource):
"""
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Insights resource and owns this resource.
:ivar category_sid: The SID of the category
:ivar name: The name of this category.
:ivar url:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
category_sid: Optional[str] = None,
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.category_sid: Optional[str] = payload.get("category_sid")
self.name: Optional[str] = payload.get("name")
self.url: Optional[str] = payload.get("url")
self._solution = {
"category_sid": category_sid or self.category_sid,
}
self._context: Optional[InsightsQuestionnairesCategoryContext] = None
@property
def _proxy(self) -> "InsightsQuestionnairesCategoryContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: InsightsQuestionnairesCategoryContext for this InsightsQuestionnairesCategoryInstance
"""
if self._context is None:
self._context = InsightsQuestionnairesCategoryContext(
self._version,
category_sid=self._solution["category_sid"],
)
return self._context
def delete(self, authorization: Union[str, object] = values.unset) -> bool:
"""
Deletes the InsightsQuestionnairesCategoryInstance
:param authorization: The Authorization HTTP request header
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete(
authorization=authorization,
)
async def delete_async(
self, authorization: Union[str, object] = values.unset
) -> bool:
"""
Asynchronous coroutine that deletes the InsightsQuestionnairesCategoryInstance
:param authorization: The Authorization HTTP request header
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async(
authorization=authorization,
)
def update(
self, name: str, authorization: Union[str, object] = values.unset
) -> "InsightsQuestionnairesCategoryInstance":
"""
Update the InsightsQuestionnairesCategoryInstance
:param name: The name of this category.
:param authorization: The Authorization HTTP request header
:returns: The updated InsightsQuestionnairesCategoryInstance
"""
return self._proxy.update(
name=name,
authorization=authorization,
)
async def update_async(
self, name: str, authorization: Union[str, object] = values.unset
) -> "InsightsQuestionnairesCategoryInstance":
"""
Asynchronous coroutine to update the InsightsQuestionnairesCategoryInstance
:param name: The name of this category.
:param authorization: The Authorization HTTP request header
:returns: The updated InsightsQuestionnairesCategoryInstance
"""
return await self._proxy.update_async(
name=name,
authorization=authorization,
)
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.FlexApi.V1.InsightsQuestionnairesCategoryInstance {}>".format(
context
)
class InsightsQuestionnairesCategoryContext(InstanceContext):
def __init__(self, version: Version, category_sid: str):
"""
Initialize the InsightsQuestionnairesCategoryContext
:param version: Version that contains the resource
:param category_sid: The SID of the category to be updated
"""
super().__init__(version)
# Path Solution
self._solution = {
"category_sid": category_sid,
}
self._uri = "/Insights/QualityManagement/Categories/{category_sid}".format(
**self._solution
)
def delete(self, authorization: Union[str, object] = values.unset) -> bool:
"""
Deletes the InsightsQuestionnairesCategoryInstance
:param authorization: The Authorization HTTP request header
:returns: True if delete succeeds, False otherwise
"""
headers = values.of(
{
"Authorization": authorization,
}
)
return self._version.delete(method="DELETE", uri=self._uri, headers=headers)
async def delete_async(
self, authorization: Union[str, object] = values.unset
) -> bool:
"""
Asynchronous coroutine that deletes the InsightsQuestionnairesCategoryInstance
:param authorization: The Authorization HTTP request header
:returns: True if delete succeeds, False otherwise
"""
headers = values.of(
{
"Authorization": authorization,
}
)
return await self._version.delete_async(
method="DELETE", uri=self._uri, headers=headers
)
def update(
self, name: str, authorization: Union[str, object] = values.unset
) -> InsightsQuestionnairesCategoryInstance:
"""
Update the InsightsQuestionnairesCategoryInstance
:param name: The name of this category.
:param authorization: The Authorization HTTP request header
:returns: The updated InsightsQuestionnairesCategoryInstance
"""
data = values.of(
{
"Name": name,
}
)
headers = values.of(
{
"Authorization": authorization,
}
)
payload = self._version.update(
method="POST", uri=self._uri, data=data, headers=headers
)
return InsightsQuestionnairesCategoryInstance(
self._version, payload, category_sid=self._solution["category_sid"]
)
async def update_async(
self, name: str, authorization: Union[str, object] = values.unset
) -> InsightsQuestionnairesCategoryInstance:
"""
Asynchronous coroutine to update the InsightsQuestionnairesCategoryInstance
:param name: The name of this category.
:param authorization: The Authorization HTTP request header
:returns: The updated InsightsQuestionnairesCategoryInstance
"""
data = values.of(
{
"Name": name,
}
)
headers = values.of(
{
"Authorization": authorization,
}
)
payload = await self._version.update_async(
method="POST", uri=self._uri, data=data, headers=headers
)
return InsightsQuestionnairesCategoryInstance(
self._version, payload, category_sid=self._solution["category_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.FlexApi.V1.InsightsQuestionnairesCategoryContext {}>".format(
context
)
class InsightsQuestionnairesCategoryPage(Page):
def get_instance(
self, payload: Dict[str, Any]
) -> InsightsQuestionnairesCategoryInstance:
"""
Build an instance of InsightsQuestionnairesCategoryInstance
:param payload: Payload response from the API
"""
return InsightsQuestionnairesCategoryInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsQuestionnairesCategoryPage>"
class InsightsQuestionnairesCategoryList(ListResource):
def __init__(self, version: Version):
"""
Initialize the InsightsQuestionnairesCategoryList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Insights/QualityManagement/Categories"
def create(
self, name: str, authorization: Union[str, object] = values.unset
) -> InsightsQuestionnairesCategoryInstance:
"""
Create the InsightsQuestionnairesCategoryInstance
:param name: The name of this category.
:param authorization: The Authorization HTTP request header
:returns: The created InsightsQuestionnairesCategoryInstance
"""
data = values.of(
{
"Name": name,
}
)
headers = values.of(
{
"Authorization": authorization,
}
)
payload = self._version.create(
method="POST", uri=self._uri, data=data, headers=headers
)
return InsightsQuestionnairesCategoryInstance(self._version, payload)
async def create_async(
self, name: str, authorization: Union[str, object] = values.unset
) -> InsightsQuestionnairesCategoryInstance:
"""
Asynchronously create the InsightsQuestionnairesCategoryInstance
:param name: The name of this category.
:param authorization: The Authorization HTTP request header
:returns: The created InsightsQuestionnairesCategoryInstance
"""
data = values.of(
{
"Name": name,
}
)
headers = values.of(
{
"Authorization": authorization,
}
)
payload = await self._version.create_async(
method="POST", uri=self._uri, data=data, headers=headers
)
return InsightsQuestionnairesCategoryInstance(self._version, payload)
def stream(
self,
authorization: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[InsightsQuestionnairesCategoryInstance]:
"""
Streams InsightsQuestionnairesCategoryInstance 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 authorization: The Authorization HTTP request header
: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(authorization=authorization, page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
authorization: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[InsightsQuestionnairesCategoryInstance]:
"""
Asynchronously streams InsightsQuestionnairesCategoryInstance 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 authorization: The Authorization HTTP request header
: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(
authorization=authorization, page_size=limits["page_size"]
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
authorization: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[InsightsQuestionnairesCategoryInstance]:
"""
Lists InsightsQuestionnairesCategoryInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str authorization: The Authorization HTTP request header
: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(
authorization=authorization,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
authorization: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[InsightsQuestionnairesCategoryInstance]:
"""
Asynchronously lists InsightsQuestionnairesCategoryInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str authorization: The Authorization HTTP request header
: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(
authorization=authorization,
limit=limit,
page_size=page_size,
)
]
def page(
self,
authorization: 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,
) -> InsightsQuestionnairesCategoryPage:
"""
Retrieve a single page of InsightsQuestionnairesCategoryInstance records from the API.
Request is executed immediately
:param authorization: The Authorization HTTP request header
: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 InsightsQuestionnairesCategoryInstance
"""
data = values.of(
{
"Authorization": authorization,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return InsightsQuestionnairesCategoryPage(self._version, response)
async def page_async(
self,
authorization: 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,
) -> InsightsQuestionnairesCategoryPage:
"""
Asynchronously retrieve a single page of InsightsQuestionnairesCategoryInstance records from the API.
Request is executed immediately
:param authorization: The Authorization HTTP request header
: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 InsightsQuestionnairesCategoryInstance
"""
data = values.of(
{
"Authorization": authorization,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return InsightsQuestionnairesCategoryPage(self._version, response)
def get_page(self, target_url: str) -> InsightsQuestionnairesCategoryPage:
"""
Retrieve a specific page of InsightsQuestionnairesCategoryInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InsightsQuestionnairesCategoryInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return InsightsQuestionnairesCategoryPage(self._version, response)
async def get_page_async(
self, target_url: str
) -> InsightsQuestionnairesCategoryPage:
"""
Asynchronously retrieve a specific page of InsightsQuestionnairesCategoryInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InsightsQuestionnairesCategoryInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return InsightsQuestionnairesCategoryPage(self._version, response)
def get(self, category_sid: str) -> InsightsQuestionnairesCategoryContext:
"""
Constructs a InsightsQuestionnairesCategoryContext
:param category_sid: The SID of the category to be updated
"""
return InsightsQuestionnairesCategoryContext(
self._version, category_sid=category_sid
)
def __call__(self, category_sid: str) -> InsightsQuestionnairesCategoryContext:
"""
Constructs a InsightsQuestionnairesCategoryContext
:param category_sid: The SID of the category to be updated
"""
return InsightsQuestionnairesCategoryContext(
self._version, category_sid=category_sid
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsQuestionnairesCategoryList>"
@@ -0,0 +1,696 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
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, 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 InsightsQuestionnairesQuestionInstance(InstanceResource):
"""
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Insights resource and owns this resource.
:ivar question_sid: The SID of the question
:ivar question: The question.
:ivar description: The description for the question.
:ivar category: The Category for the question.
:ivar answer_set_id: The answer_set for the question.
:ivar allow_na: The flag to enable for disable NA for answer.
:ivar usage: Integer value that tells a particular question is used by how many questionnaires
:ivar answer_set: Set of answers for the question
:ivar url:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
question_sid: Optional[str] = None,
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.question_sid: Optional[str] = payload.get("question_sid")
self.question: Optional[str] = payload.get("question")
self.description: Optional[str] = payload.get("description")
self.category: Optional[Dict[str, object]] = payload.get("category")
self.answer_set_id: Optional[str] = payload.get("answer_set_id")
self.allow_na: Optional[bool] = payload.get("allow_na")
self.usage: Optional[int] = deserialize.integer(payload.get("usage"))
self.answer_set: Optional[Dict[str, object]] = payload.get("answer_set")
self.url: Optional[str] = payload.get("url")
self._solution = {
"question_sid": question_sid or self.question_sid,
}
self._context: Optional[InsightsQuestionnairesQuestionContext] = None
@property
def _proxy(self) -> "InsightsQuestionnairesQuestionContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: InsightsQuestionnairesQuestionContext for this InsightsQuestionnairesQuestionInstance
"""
if self._context is None:
self._context = InsightsQuestionnairesQuestionContext(
self._version,
question_sid=self._solution["question_sid"],
)
return self._context
def delete(self, authorization: Union[str, object] = values.unset) -> bool:
"""
Deletes the InsightsQuestionnairesQuestionInstance
:param authorization: The Authorization HTTP request header
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete(
authorization=authorization,
)
async def delete_async(
self, authorization: Union[str, object] = values.unset
) -> bool:
"""
Asynchronous coroutine that deletes the InsightsQuestionnairesQuestionInstance
:param authorization: The Authorization HTTP request header
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async(
authorization=authorization,
)
def update(
self,
allow_na: bool,
authorization: Union[str, object] = values.unset,
category_sid: Union[str, object] = values.unset,
question: Union[str, object] = values.unset,
description: Union[str, object] = values.unset,
answer_set_id: Union[str, object] = values.unset,
) -> "InsightsQuestionnairesQuestionInstance":
"""
Update the InsightsQuestionnairesQuestionInstance
:param allow_na: The flag to enable for disable NA for answer.
:param authorization: The Authorization HTTP request header
:param category_sid: The SID of the category
:param question: The question.
:param description: The description for the question.
:param answer_set_id: The answer_set for the question.
:returns: The updated InsightsQuestionnairesQuestionInstance
"""
return self._proxy.update(
allow_na=allow_na,
authorization=authorization,
category_sid=category_sid,
question=question,
description=description,
answer_set_id=answer_set_id,
)
async def update_async(
self,
allow_na: bool,
authorization: Union[str, object] = values.unset,
category_sid: Union[str, object] = values.unset,
question: Union[str, object] = values.unset,
description: Union[str, object] = values.unset,
answer_set_id: Union[str, object] = values.unset,
) -> "InsightsQuestionnairesQuestionInstance":
"""
Asynchronous coroutine to update the InsightsQuestionnairesQuestionInstance
:param allow_na: The flag to enable for disable NA for answer.
:param authorization: The Authorization HTTP request header
:param category_sid: The SID of the category
:param question: The question.
:param description: The description for the question.
:param answer_set_id: The answer_set for the question.
:returns: The updated InsightsQuestionnairesQuestionInstance
"""
return await self._proxy.update_async(
allow_na=allow_na,
authorization=authorization,
category_sid=category_sid,
question=question,
description=description,
answer_set_id=answer_set_id,
)
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.FlexApi.V1.InsightsQuestionnairesQuestionInstance {}>".format(
context
)
class InsightsQuestionnairesQuestionContext(InstanceContext):
def __init__(self, version: Version, question_sid: str):
"""
Initialize the InsightsQuestionnairesQuestionContext
:param version: Version that contains the resource
:param question_sid: The SID of the question
"""
super().__init__(version)
# Path Solution
self._solution = {
"question_sid": question_sid,
}
self._uri = "/Insights/QualityManagement/Questions/{question_sid}".format(
**self._solution
)
def delete(self, authorization: Union[str, object] = values.unset) -> bool:
"""
Deletes the InsightsQuestionnairesQuestionInstance
:param authorization: The Authorization HTTP request header
:returns: True if delete succeeds, False otherwise
"""
headers = values.of(
{
"Authorization": authorization,
}
)
return self._version.delete(method="DELETE", uri=self._uri, headers=headers)
async def delete_async(
self, authorization: Union[str, object] = values.unset
) -> bool:
"""
Asynchronous coroutine that deletes the InsightsQuestionnairesQuestionInstance
:param authorization: The Authorization HTTP request header
:returns: True if delete succeeds, False otherwise
"""
headers = values.of(
{
"Authorization": authorization,
}
)
return await self._version.delete_async(
method="DELETE", uri=self._uri, headers=headers
)
def update(
self,
allow_na: bool,
authorization: Union[str, object] = values.unset,
category_sid: Union[str, object] = values.unset,
question: Union[str, object] = values.unset,
description: Union[str, object] = values.unset,
answer_set_id: Union[str, object] = values.unset,
) -> InsightsQuestionnairesQuestionInstance:
"""
Update the InsightsQuestionnairesQuestionInstance
:param allow_na: The flag to enable for disable NA for answer.
:param authorization: The Authorization HTTP request header
:param category_sid: The SID of the category
:param question: The question.
:param description: The description for the question.
:param answer_set_id: The answer_set for the question.
:returns: The updated InsightsQuestionnairesQuestionInstance
"""
data = values.of(
{
"AllowNa": allow_na,
"CategorySid": category_sid,
"Question": question,
"Description": description,
"AnswerSetId": answer_set_id,
}
)
headers = values.of(
{
"Authorization": authorization,
}
)
payload = self._version.update(
method="POST", uri=self._uri, data=data, headers=headers
)
return InsightsQuestionnairesQuestionInstance(
self._version, payload, question_sid=self._solution["question_sid"]
)
async def update_async(
self,
allow_na: bool,
authorization: Union[str, object] = values.unset,
category_sid: Union[str, object] = values.unset,
question: Union[str, object] = values.unset,
description: Union[str, object] = values.unset,
answer_set_id: Union[str, object] = values.unset,
) -> InsightsQuestionnairesQuestionInstance:
"""
Asynchronous coroutine to update the InsightsQuestionnairesQuestionInstance
:param allow_na: The flag to enable for disable NA for answer.
:param authorization: The Authorization HTTP request header
:param category_sid: The SID of the category
:param question: The question.
:param description: The description for the question.
:param answer_set_id: The answer_set for the question.
:returns: The updated InsightsQuestionnairesQuestionInstance
"""
data = values.of(
{
"AllowNa": allow_na,
"CategorySid": category_sid,
"Question": question,
"Description": description,
"AnswerSetId": answer_set_id,
}
)
headers = values.of(
{
"Authorization": authorization,
}
)
payload = await self._version.update_async(
method="POST", uri=self._uri, data=data, headers=headers
)
return InsightsQuestionnairesQuestionInstance(
self._version, payload, question_sid=self._solution["question_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.FlexApi.V1.InsightsQuestionnairesQuestionContext {}>".format(
context
)
class InsightsQuestionnairesQuestionPage(Page):
def get_instance(
self, payload: Dict[str, Any]
) -> InsightsQuestionnairesQuestionInstance:
"""
Build an instance of InsightsQuestionnairesQuestionInstance
:param payload: Payload response from the API
"""
return InsightsQuestionnairesQuestionInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsQuestionnairesQuestionPage>"
class InsightsQuestionnairesQuestionList(ListResource):
def __init__(self, version: Version):
"""
Initialize the InsightsQuestionnairesQuestionList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Insights/QualityManagement/Questions"
def create(
self,
category_sid: str,
question: str,
answer_set_id: str,
allow_na: bool,
authorization: Union[str, object] = values.unset,
description: Union[str, object] = values.unset,
) -> InsightsQuestionnairesQuestionInstance:
"""
Create the InsightsQuestionnairesQuestionInstance
:param category_sid: The SID of the category
:param question: The question.
:param answer_set_id: The answer_set for the question.
:param allow_na: The flag to enable for disable NA for answer.
:param authorization: The Authorization HTTP request header
:param description: The description for the question.
:returns: The created InsightsQuestionnairesQuestionInstance
"""
data = values.of(
{
"CategorySid": category_sid,
"Question": question,
"AnswerSetId": answer_set_id,
"AllowNa": allow_na,
"Description": description,
}
)
headers = values.of(
{
"Authorization": authorization,
}
)
payload = self._version.create(
method="POST", uri=self._uri, data=data, headers=headers
)
return InsightsQuestionnairesQuestionInstance(self._version, payload)
async def create_async(
self,
category_sid: str,
question: str,
answer_set_id: str,
allow_na: bool,
authorization: Union[str, object] = values.unset,
description: Union[str, object] = values.unset,
) -> InsightsQuestionnairesQuestionInstance:
"""
Asynchronously create the InsightsQuestionnairesQuestionInstance
:param category_sid: The SID of the category
:param question: The question.
:param answer_set_id: The answer_set for the question.
:param allow_na: The flag to enable for disable NA for answer.
:param authorization: The Authorization HTTP request header
:param description: The description for the question.
:returns: The created InsightsQuestionnairesQuestionInstance
"""
data = values.of(
{
"CategorySid": category_sid,
"Question": question,
"AnswerSetId": answer_set_id,
"AllowNa": allow_na,
"Description": description,
}
)
headers = values.of(
{
"Authorization": authorization,
}
)
payload = await self._version.create_async(
method="POST", uri=self._uri, data=data, headers=headers
)
return InsightsQuestionnairesQuestionInstance(self._version, payload)
def stream(
self,
authorization: Union[str, object] = values.unset,
category_sid: Union[List[str], object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[InsightsQuestionnairesQuestionInstance]:
"""
Streams InsightsQuestionnairesQuestionInstance 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 authorization: The Authorization HTTP request header
:param List[str] category_sid: The list of category SIDs
: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(
authorization=authorization,
category_sid=category_sid,
page_size=limits["page_size"],
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
authorization: Union[str, object] = values.unset,
category_sid: Union[List[str], object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[InsightsQuestionnairesQuestionInstance]:
"""
Asynchronously streams InsightsQuestionnairesQuestionInstance 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 authorization: The Authorization HTTP request header
:param List[str] category_sid: The list of category SIDs
: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(
authorization=authorization,
category_sid=category_sid,
page_size=limits["page_size"],
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
authorization: Union[str, object] = values.unset,
category_sid: Union[List[str], object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[InsightsQuestionnairesQuestionInstance]:
"""
Lists InsightsQuestionnairesQuestionInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str authorization: The Authorization HTTP request header
:param List[str] category_sid: The list of category SIDs
: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(
authorization=authorization,
category_sid=category_sid,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
authorization: Union[str, object] = values.unset,
category_sid: Union[List[str], object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[InsightsQuestionnairesQuestionInstance]:
"""
Asynchronously lists InsightsQuestionnairesQuestionInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str authorization: The Authorization HTTP request header
:param List[str] category_sid: The list of category SIDs
: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(
authorization=authorization,
category_sid=category_sid,
limit=limit,
page_size=page_size,
)
]
def page(
self,
authorization: Union[str, object] = values.unset,
category_sid: 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,
) -> InsightsQuestionnairesQuestionPage:
"""
Retrieve a single page of InsightsQuestionnairesQuestionInstance records from the API.
Request is executed immediately
:param authorization: The Authorization HTTP request header
:param category_sid: The list of category SIDs
: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 InsightsQuestionnairesQuestionInstance
"""
data = values.of(
{
"Authorization": authorization,
"CategorySid": serialize.map(category_sid, lambda e: e),
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return InsightsQuestionnairesQuestionPage(self._version, response)
async def page_async(
self,
authorization: Union[str, object] = values.unset,
category_sid: 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,
) -> InsightsQuestionnairesQuestionPage:
"""
Asynchronously retrieve a single page of InsightsQuestionnairesQuestionInstance records from the API.
Request is executed immediately
:param authorization: The Authorization HTTP request header
:param category_sid: The list of category SIDs
: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 InsightsQuestionnairesQuestionInstance
"""
data = values.of(
{
"Authorization": authorization,
"CategorySid": serialize.map(category_sid, 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 InsightsQuestionnairesQuestionPage(self._version, response)
def get_page(self, target_url: str) -> InsightsQuestionnairesQuestionPage:
"""
Retrieve a specific page of InsightsQuestionnairesQuestionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InsightsQuestionnairesQuestionInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return InsightsQuestionnairesQuestionPage(self._version, response)
async def get_page_async(
self, target_url: str
) -> InsightsQuestionnairesQuestionPage:
"""
Asynchronously retrieve a specific page of InsightsQuestionnairesQuestionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InsightsQuestionnairesQuestionInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return InsightsQuestionnairesQuestionPage(self._version, response)
def get(self, question_sid: str) -> InsightsQuestionnairesQuestionContext:
"""
Constructs a InsightsQuestionnairesQuestionContext
:param question_sid: The SID of the question
"""
return InsightsQuestionnairesQuestionContext(
self._version, question_sid=question_sid
)
def __call__(self, question_sid: str) -> InsightsQuestionnairesQuestionContext:
"""
Constructs a InsightsQuestionnairesQuestionContext
:param question_sid: The SID of the question
"""
return InsightsQuestionnairesQuestionContext(
self._version, question_sid=question_sid
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsQuestionnairesQuestionList>"
@@ -0,0 +1,375 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
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, Iterator, AsyncIterator
from twilio.base import serialize, 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 InsightsSegmentsInstance(InstanceResource):
"""
:ivar segment_id: To unique id of the segment
:ivar external_id: The unique id for the conversation.
:ivar queue:
:ivar external_contact:
:ivar external_segment_link_id: The uuid for the external_segment_link.
:ivar date: The date of the conversation.
:ivar account_id: The unique id for the account.
:ivar external_segment_link: The hyperlink to recording of the task event.
:ivar agent_id: The unique id for the agent.
:ivar agent_phone: The phone number of the agent.
:ivar agent_name: The name of the agent.
:ivar agent_team_name: The team name to which agent belongs.
:ivar agent_team_name_in_hierarchy: he team name to which agent belongs.
:ivar agent_link: The link to the agent conversation.
:ivar customer_phone: The phone number of the customer.
:ivar customer_name: The name of the customer.
:ivar customer_link: The link to the customer conversation.
:ivar segment_recording_offset: The offset value for the recording.
:ivar media: The media identifiers of the conversation.
:ivar assessment_type: The type of the assessment.
:ivar assessment_percentage: The percentage scored on the Assessments.
:ivar url:
"""
def __init__(self, version: Version, payload: Dict[str, Any]):
super().__init__(version)
self.segment_id: Optional[str] = payload.get("segment_id")
self.external_id: Optional[str] = payload.get("external_id")
self.queue: Optional[str] = payload.get("queue")
self.external_contact: Optional[str] = payload.get("external_contact")
self.external_segment_link_id: Optional[str] = payload.get(
"external_segment_link_id"
)
self.date: Optional[str] = payload.get("date")
self.account_id: Optional[str] = payload.get("account_id")
self.external_segment_link: Optional[str] = payload.get("external_segment_link")
self.agent_id: Optional[str] = payload.get("agent_id")
self.agent_phone: Optional[str] = payload.get("agent_phone")
self.agent_name: Optional[str] = payload.get("agent_name")
self.agent_team_name: Optional[str] = payload.get("agent_team_name")
self.agent_team_name_in_hierarchy: Optional[str] = payload.get(
"agent_team_name_in_hierarchy"
)
self.agent_link: Optional[str] = payload.get("agent_link")
self.customer_phone: Optional[str] = payload.get("customer_phone")
self.customer_name: Optional[str] = payload.get("customer_name")
self.customer_link: Optional[str] = payload.get("customer_link")
self.segment_recording_offset: Optional[str] = payload.get(
"segment_recording_offset"
)
self.media: Optional[Dict[str, object]] = payload.get("media")
self.assessment_type: Optional[Dict[str, object]] = payload.get(
"assessment_type"
)
self.assessment_percentage: Optional[Dict[str, object]] = payload.get(
"assessment_percentage"
)
self.url: Optional[str] = payload.get("url")
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsSegmentsInstance>"
class InsightsSegmentsPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> InsightsSegmentsInstance:
"""
Build an instance of InsightsSegmentsInstance
:param payload: Payload response from the API
"""
return InsightsSegmentsInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsSegmentsPage>"
class InsightsSegmentsList(ListResource):
def __init__(self, version: Version):
"""
Initialize the InsightsSegmentsList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Insights/Segments"
def stream(
self,
authorization: Union[str, object] = values.unset,
segment_id: Union[str, object] = values.unset,
reservation_id: Union[List[str], object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[InsightsSegmentsInstance]:
"""
Streams InsightsSegmentsInstance 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 authorization: The Authorization HTTP request header
:param str segment_id: To unique id of the segment
:param List[str] reservation_id: The list of reservation Ids
: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(
authorization=authorization,
segment_id=segment_id,
reservation_id=reservation_id,
page_size=limits["page_size"],
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
authorization: Union[str, object] = values.unset,
segment_id: Union[str, object] = values.unset,
reservation_id: Union[List[str], object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[InsightsSegmentsInstance]:
"""
Asynchronously streams InsightsSegmentsInstance 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 authorization: The Authorization HTTP request header
:param str segment_id: To unique id of the segment
:param List[str] reservation_id: The list of reservation Ids
: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(
authorization=authorization,
segment_id=segment_id,
reservation_id=reservation_id,
page_size=limits["page_size"],
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
authorization: Union[str, object] = values.unset,
segment_id: Union[str, object] = values.unset,
reservation_id: Union[List[str], object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[InsightsSegmentsInstance]:
"""
Lists InsightsSegmentsInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str authorization: The Authorization HTTP request header
:param str segment_id: To unique id of the segment
:param List[str] reservation_id: The list of reservation Ids
: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(
authorization=authorization,
segment_id=segment_id,
reservation_id=reservation_id,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
authorization: Union[str, object] = values.unset,
segment_id: Union[str, object] = values.unset,
reservation_id: Union[List[str], object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[InsightsSegmentsInstance]:
"""
Asynchronously lists InsightsSegmentsInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str authorization: The Authorization HTTP request header
:param str segment_id: To unique id of the segment
:param List[str] reservation_id: The list of reservation Ids
: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(
authorization=authorization,
segment_id=segment_id,
reservation_id=reservation_id,
limit=limit,
page_size=page_size,
)
]
def page(
self,
authorization: Union[str, object] = values.unset,
segment_id: Union[str, object] = values.unset,
reservation_id: 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,
) -> InsightsSegmentsPage:
"""
Retrieve a single page of InsightsSegmentsInstance records from the API.
Request is executed immediately
:param authorization: The Authorization HTTP request header
:param segment_id: To unique id of the segment
:param reservation_id: The list of reservation Ids
: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 InsightsSegmentsInstance
"""
data = values.of(
{
"Authorization": authorization,
"SegmentId": segment_id,
"ReservationId": serialize.map(reservation_id, lambda e: e),
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return InsightsSegmentsPage(self._version, response)
async def page_async(
self,
authorization: Union[str, object] = values.unset,
segment_id: Union[str, object] = values.unset,
reservation_id: 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,
) -> InsightsSegmentsPage:
"""
Asynchronously retrieve a single page of InsightsSegmentsInstance records from the API.
Request is executed immediately
:param authorization: The Authorization HTTP request header
:param segment_id: To unique id of the segment
:param reservation_id: The list of reservation Ids
: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 InsightsSegmentsInstance
"""
data = values.of(
{
"Authorization": authorization,
"SegmentId": segment_id,
"ReservationId": serialize.map(reservation_id, 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 InsightsSegmentsPage(self._version, response)
def get_page(self, target_url: str) -> InsightsSegmentsPage:
"""
Retrieve a specific page of InsightsSegmentsInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InsightsSegmentsInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return InsightsSegmentsPage(self._version, response)
async def get_page_async(self, target_url: str) -> InsightsSegmentsPage:
"""
Asynchronously retrieve a specific page of InsightsSegmentsInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InsightsSegmentsInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return InsightsSegmentsPage(self._version, response)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsSegmentsList>"
@@ -0,0 +1,190 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
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 InsightsSessionInstance(InstanceResource):
"""
:ivar workspace_id: Unique ID to identify the user's workspace
:ivar session_expiry: The session expiry date and time, given in ISO 8601 format.
:ivar session_id: The unique ID for the session
:ivar base_url: The base URL to fetch reports and dashboards
:ivar url: The URL of this resource.
"""
def __init__(self, version: Version, payload: Dict[str, Any]):
super().__init__(version)
self.workspace_id: Optional[str] = payload.get("workspace_id")
self.session_expiry: Optional[str] = payload.get("session_expiry")
self.session_id: Optional[str] = payload.get("session_id")
self.base_url: Optional[str] = payload.get("base_url")
self.url: Optional[str] = payload.get("url")
self._context: Optional[InsightsSessionContext] = None
@property
def _proxy(self) -> "InsightsSessionContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: InsightsSessionContext for this InsightsSessionInstance
"""
if self._context is None:
self._context = InsightsSessionContext(
self._version,
)
return self._context
def create(
self, authorization: Union[str, object] = values.unset
) -> "InsightsSessionInstance":
"""
Create the InsightsSessionInstance
:param authorization: The Authorization HTTP request header
:returns: The created InsightsSessionInstance
"""
return self._proxy.create(
authorization=authorization,
)
async def create_async(
self, authorization: Union[str, object] = values.unset
) -> "InsightsSessionInstance":
"""
Asynchronous coroutine to create the InsightsSessionInstance
:param authorization: The Authorization HTTP request header
:returns: The created InsightsSessionInstance
"""
return await self._proxy.create_async(
authorization=authorization,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsSessionInstance>"
class InsightsSessionContext(InstanceContext):
def __init__(self, version: Version):
"""
Initialize the InsightsSessionContext
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Insights/Session"
def create(
self, authorization: Union[str, object] = values.unset
) -> InsightsSessionInstance:
"""
Create the InsightsSessionInstance
:param authorization: The Authorization HTTP request header
:returns: The created InsightsSessionInstance
"""
data = values.of(
{
"Authorization": authorization,
}
)
payload = self._version.create(method="POST", uri=self._uri, data=data)
return InsightsSessionInstance(self._version, payload)
async def create_async(
self, authorization: Union[str, object] = values.unset
) -> InsightsSessionInstance:
"""
Asynchronous coroutine to create the InsightsSessionInstance
:param authorization: The Authorization HTTP request header
:returns: The created InsightsSessionInstance
"""
data = values.of(
{
"Authorization": authorization,
}
)
payload = await self._version.create_async(
method="POST", uri=self._uri, data=data
)
return InsightsSessionInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsSessionContext>"
class InsightsSessionList(ListResource):
def __init__(self, version: Version):
"""
Initialize the InsightsSessionList
:param version: Version that contains the resource
"""
super().__init__(version)
def get(self) -> InsightsSessionContext:
"""
Constructs a InsightsSessionContext
"""
return InsightsSessionContext(self._version)
def __call__(self) -> InsightsSessionContext:
"""
Constructs a InsightsSessionContext
"""
return InsightsSessionContext(self._version)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsSessionList>"
@@ -0,0 +1,92 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, Optional
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
class InsightsSettingsAnswerSetsInstance(InstanceResource):
"""
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Insights resource and owns this resource.
:ivar answer_sets: The lis of answer sets
:ivar answer_set_categories: The list of answer set categories
:ivar not_applicable: The details for not applicable answer set
:ivar url:
"""
def __init__(self, version: Version, payload: Dict[str, Any]):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.answer_sets: Optional[Dict[str, object]] = payload.get("answer_sets")
self.answer_set_categories: Optional[Dict[str, object]] = payload.get(
"answer_set_categories"
)
self.not_applicable: Optional[Dict[str, object]] = payload.get("not_applicable")
self.url: Optional[str] = payload.get("url")
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsSettingsAnswerSetsInstance>"
class InsightsSettingsAnswerSetsList(ListResource):
def __init__(self, version: Version):
"""
Initialize the InsightsSettingsAnswerSetsList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Insights/QualityManagement/Settings/AnswerSets"
def fetch(self) -> InsightsSettingsAnswerSetsInstance:
"""
Asynchronously fetch the InsightsSettingsAnswerSetsInstance
:returns: The fetched InsightsSettingsAnswerSetsInstance
"""
payload = self._version.fetch(method="GET", uri=self._uri)
return InsightsSettingsAnswerSetsInstance(self._version, payload)
async def fetch_async(self) -> InsightsSettingsAnswerSetsInstance:
"""
Asynchronously fetch the InsightsSettingsAnswerSetsInstance
:returns: The fetched InsightsSettingsAnswerSetsInstance
"""
payload = await self._version.fetch_async(method="GET", uri=self._uri)
return InsightsSettingsAnswerSetsInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsSettingsAnswerSetsList>"
@@ -0,0 +1,86 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, Optional
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
class InsightsSettingsCommentInstance(InstanceResource):
"""
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Insights resource and owns this resource.
:ivar comments:
:ivar url:
"""
def __init__(self, version: Version, payload: Dict[str, Any]):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.comments: Optional[Dict[str, object]] = payload.get("comments")
self.url: Optional[str] = payload.get("url")
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsSettingsCommentInstance>"
class InsightsSettingsCommentList(ListResource):
def __init__(self, version: Version):
"""
Initialize the InsightsSettingsCommentList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Insights/QualityManagement/Settings/CommentTags"
def fetch(self) -> InsightsSettingsCommentInstance:
"""
Asynchronously fetch the InsightsSettingsCommentInstance
:returns: The fetched InsightsSettingsCommentInstance
"""
payload = self._version.fetch(method="GET", uri=self._uri)
return InsightsSettingsCommentInstance(self._version, payload)
async def fetch_async(self) -> InsightsSettingsCommentInstance:
"""
Asynchronously fetch the InsightsSettingsCommentInstance
:returns: The fetched InsightsSettingsCommentInstance
"""
payload = await self._version.fetch_async(method="GET", uri=self._uri)
return InsightsSettingsCommentInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsSettingsCommentList>"
@@ -0,0 +1,192 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
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 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 InsightsUserRolesInstance(InstanceResource):
"""
:ivar roles: Flex Insights roles for the user
:ivar url:
"""
def __init__(self, version: Version, payload: Dict[str, Any]):
super().__init__(version)
self.roles: Optional[List[str]] = payload.get("roles")
self.url: Optional[str] = payload.get("url")
self._context: Optional[InsightsUserRolesContext] = None
@property
def _proxy(self) -> "InsightsUserRolesContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: InsightsUserRolesContext for this InsightsUserRolesInstance
"""
if self._context is None:
self._context = InsightsUserRolesContext(
self._version,
)
return self._context
def fetch(
self, authorization: Union[str, object] = values.unset
) -> "InsightsUserRolesInstance":
"""
Fetch the InsightsUserRolesInstance
:param authorization: The Authorization HTTP request header
:returns: The fetched InsightsUserRolesInstance
"""
return self._proxy.fetch(
authorization=authorization,
)
async def fetch_async(
self, authorization: Union[str, object] = values.unset
) -> "InsightsUserRolesInstance":
"""
Asynchronous coroutine to fetch the InsightsUserRolesInstance
:param authorization: The Authorization HTTP request header
:returns: The fetched InsightsUserRolesInstance
"""
return await self._proxy.fetch_async(
authorization=authorization,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsUserRolesInstance>"
class InsightsUserRolesContext(InstanceContext):
def __init__(self, version: Version):
"""
Initialize the InsightsUserRolesContext
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Insights/UserRoles"
def fetch(
self, authorization: Union[str, object] = values.unset
) -> InsightsUserRolesInstance:
"""
Fetch the InsightsUserRolesInstance
:param authorization: The Authorization HTTP request header
:returns: The fetched InsightsUserRolesInstance
"""
data = values.of(
{
"Authorization": authorization,
}
)
payload = self._version.fetch(method="GET", uri=self._uri, params=data)
return InsightsUserRolesInstance(
self._version,
payload,
)
async def fetch_async(
self, authorization: Union[str, object] = values.unset
) -> InsightsUserRolesInstance:
"""
Asynchronous coroutine to fetch the InsightsUserRolesInstance
:param authorization: The Authorization HTTP request header
:returns: The fetched InsightsUserRolesInstance
"""
data = values.of(
{
"Authorization": authorization,
}
)
payload = await self._version.fetch_async(
method="GET", uri=self._uri, params=data
)
return InsightsUserRolesInstance(
self._version,
payload,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsUserRolesContext>"
class InsightsUserRolesList(ListResource):
def __init__(self, version: Version):
"""
Initialize the InsightsUserRolesList
:param version: Version that contains the resource
"""
super().__init__(version)
def get(self) -> InsightsUserRolesContext:
"""
Constructs a InsightsUserRolesContext
"""
return InsightsUserRolesContext(self._version)
def __call__(self) -> InsightsUserRolesContext:
"""
Constructs a InsightsUserRolesContext
"""
return InsightsUserRolesContext(self._version)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InsightsUserRolesList>"
@@ -0,0 +1,282 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
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 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.rest.flex_api.v1.interaction.interaction_channel import (
InteractionChannelList,
)
class InteractionInstance(InstanceResource):
"""
:ivar sid: The unique string created by Twilio to identify an Interaction resource, prefixed with KD.
:ivar channel: A JSON object that defines the Interactions communication channel and includes details about the channel. See the [Outbound SMS](https://www.twilio.com/docs/flex/developer/conversations/interactions-api/interactions#agent-initiated-outbound-interactions) and [inbound (API-initiated)](https://www.twilio.com/docs/flex/developer/conversations/interactions-api/interactions#api-initiated-contact) Channel object examples.
:ivar routing: A JSON Object representing the routing rules for the Interaction Channel. See [Outbound SMS Example](https://www.twilio.com/docs/flex/developer/conversations/interactions-api/interactions#agent-initiated-outbound-interactions) for an example Routing object. The Interactions resource uses TaskRouter for all routing functionality. All attributes in the Routing object on your Interaction request body are added “as is” to the task. For a list of known attributes consumed by the Flex UI and/or Flex Insights, see [Known Task Attributes](https://www.twilio.com/docs/flex/developer/conversations/interactions-api#task-attributes).
:ivar url:
:ivar links:
:ivar interaction_context_sid:
"""
def __init__(
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.channel: Optional[Dict[str, object]] = payload.get("channel")
self.routing: Optional[Dict[str, object]] = payload.get("routing")
self.url: Optional[str] = payload.get("url")
self.links: Optional[Dict[str, object]] = payload.get("links")
self.interaction_context_sid: Optional[str] = payload.get(
"interaction_context_sid"
)
self._solution = {
"sid": sid or self.sid,
}
self._context: Optional[InteractionContext] = None
@property
def _proxy(self) -> "InteractionContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: InteractionContext for this InteractionInstance
"""
if self._context is None:
self._context = InteractionContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "InteractionInstance":
"""
Fetch the InteractionInstance
:returns: The fetched InteractionInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "InteractionInstance":
"""
Asynchronous coroutine to fetch the InteractionInstance
:returns: The fetched InteractionInstance
"""
return await self._proxy.fetch_async()
@property
def channels(self) -> InteractionChannelList:
"""
Access the channels
"""
return self._proxy.channels
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.FlexApi.V1.InteractionInstance {}>".format(context)
class InteractionContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the InteractionContext
:param version: Version that contains the resource
:param sid: The SID of the Interaction resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/Interactions/{sid}".format(**self._solution)
self._channels: Optional[InteractionChannelList] = None
def fetch(self) -> InteractionInstance:
"""
Fetch the InteractionInstance
:returns: The fetched InteractionInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return InteractionInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> InteractionInstance:
"""
Asynchronous coroutine to fetch the InteractionInstance
:returns: The fetched InteractionInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return InteractionInstance(
self._version,
payload,
sid=self._solution["sid"],
)
@property
def channels(self) -> InteractionChannelList:
"""
Access the channels
"""
if self._channels is None:
self._channels = InteractionChannelList(
self._version,
self._solution["sid"],
)
return self._channels
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.FlexApi.V1.InteractionContext {}>".format(context)
class InteractionList(ListResource):
def __init__(self, version: Version):
"""
Initialize the InteractionList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Interactions"
def create(
self,
channel: object,
routing: object,
interaction_context_sid: Union[str, object] = values.unset,
) -> InteractionInstance:
"""
Create the InteractionInstance
:param channel: The Interaction's channel.
:param routing: The Interaction's routing logic.
:param interaction_context_sid: The Interaction context sid is used for adding a context lookup sid
:returns: The created InteractionInstance
"""
data = values.of(
{
"Channel": serialize.object(channel),
"Routing": serialize.object(routing),
"InteractionContextSid": interaction_context_sid,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return InteractionInstance(self._version, payload)
async def create_async(
self,
channel: object,
routing: object,
interaction_context_sid: Union[str, object] = values.unset,
) -> InteractionInstance:
"""
Asynchronously create the InteractionInstance
:param channel: The Interaction's channel.
:param routing: The Interaction's routing logic.
:param interaction_context_sid: The Interaction context sid is used for adding a context lookup sid
:returns: The created InteractionInstance
"""
data = values.of(
{
"Channel": serialize.object(channel),
"Routing": serialize.object(routing),
"InteractionContextSid": interaction_context_sid,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return InteractionInstance(self._version, payload)
def get(self, sid: str) -> InteractionContext:
"""
Constructs a InteractionContext
:param sid: The SID of the Interaction resource to fetch.
"""
return InteractionContext(self._version, sid=sid)
def __call__(self, sid: str) -> InteractionContext:
"""
Constructs a InteractionContext
:param sid: The SID of the Interaction resource to fetch.
"""
return InteractionContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InteractionList>"
@@ -0,0 +1,595 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
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, 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.flex_api.v1.interaction.interaction_channel.interaction_channel_invite import (
InteractionChannelInviteList,
)
from twilio.rest.flex_api.v1.interaction.interaction_channel.interaction_channel_participant import (
InteractionChannelParticipantList,
)
class InteractionChannelInstance(InstanceResource):
class ChannelStatus(object):
SETUP = "setup"
ACTIVE = "active"
FAILED = "failed"
CLOSED = "closed"
INACTIVE = "inactive"
class Type(object):
VOICE = "voice"
SMS = "sms"
EMAIL = "email"
WEB = "web"
WHATSAPP = "whatsapp"
CHAT = "chat"
MESSENGER = "messenger"
GBM = "gbm"
class UpdateChannelStatus(object):
CLOSED = "closed"
INACTIVE = "inactive"
"""
:ivar sid: The unique string created by Twilio to identify an Interaction Channel resource, prefixed with UO.
:ivar interaction_sid: The unique string created by Twilio to identify an Interaction resource, prefixed with KD.
:ivar type:
:ivar status:
:ivar error_code: The Twilio error code for a failed channel.
:ivar error_message: The error message for a failed channel.
:ivar url:
:ivar links:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
interaction_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.interaction_sid: Optional[str] = payload.get("interaction_sid")
self.type: Optional["InteractionChannelInstance.Type"] = payload.get("type")
self.status: Optional["InteractionChannelInstance.ChannelStatus"] = payload.get(
"status"
)
self.error_code: Optional[int] = deserialize.integer(payload.get("error_code"))
self.error_message: Optional[str] = payload.get("error_message")
self.url: Optional[str] = payload.get("url")
self.links: Optional[Dict[str, object]] = payload.get("links")
self._solution = {
"interaction_sid": interaction_sid,
"sid": sid or self.sid,
}
self._context: Optional[InteractionChannelContext] = None
@property
def _proxy(self) -> "InteractionChannelContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: InteractionChannelContext for this InteractionChannelInstance
"""
if self._context is None:
self._context = InteractionChannelContext(
self._version,
interaction_sid=self._solution["interaction_sid"],
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "InteractionChannelInstance":
"""
Fetch the InteractionChannelInstance
:returns: The fetched InteractionChannelInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "InteractionChannelInstance":
"""
Asynchronous coroutine to fetch the InteractionChannelInstance
:returns: The fetched InteractionChannelInstance
"""
return await self._proxy.fetch_async()
def update(
self,
status: "InteractionChannelInstance.UpdateChannelStatus",
routing: Union[object, object] = values.unset,
) -> "InteractionChannelInstance":
"""
Update the InteractionChannelInstance
:param status:
:param routing: It changes the state of associated tasks. Routing status is required, When the channel status is set to `inactive`. Allowed Value for routing status is `closed`. Otherwise Optional, if not specified, all tasks will be set to `wrapping`.
:returns: The updated InteractionChannelInstance
"""
return self._proxy.update(
status=status,
routing=routing,
)
async def update_async(
self,
status: "InteractionChannelInstance.UpdateChannelStatus",
routing: Union[object, object] = values.unset,
) -> "InteractionChannelInstance":
"""
Asynchronous coroutine to update the InteractionChannelInstance
:param status:
:param routing: It changes the state of associated tasks. Routing status is required, When the channel status is set to `inactive`. Allowed Value for routing status is `closed`. Otherwise Optional, if not specified, all tasks will be set to `wrapping`.
:returns: The updated InteractionChannelInstance
"""
return await self._proxy.update_async(
status=status,
routing=routing,
)
@property
def invites(self) -> InteractionChannelInviteList:
"""
Access the invites
"""
return self._proxy.invites
@property
def participants(self) -> InteractionChannelParticipantList:
"""
Access the participants
"""
return self._proxy.participants
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.FlexApi.V1.InteractionChannelInstance {}>".format(context)
class InteractionChannelContext(InstanceContext):
def __init__(self, version: Version, interaction_sid: str, sid: str):
"""
Initialize the InteractionChannelContext
:param version: Version that contains the resource
:param interaction_sid: The unique string created by Twilio to identify an Interaction resource, prefixed with KD.
:param sid: The unique string created by Twilio to identify an Interaction Channel resource, prefixed with UO.
"""
super().__init__(version)
# Path Solution
self._solution = {
"interaction_sid": interaction_sid,
"sid": sid,
}
self._uri = "/Interactions/{interaction_sid}/Channels/{sid}".format(
**self._solution
)
self._invites: Optional[InteractionChannelInviteList] = None
self._participants: Optional[InteractionChannelParticipantList] = None
def fetch(self) -> InteractionChannelInstance:
"""
Fetch the InteractionChannelInstance
:returns: The fetched InteractionChannelInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return InteractionChannelInstance(
self._version,
payload,
interaction_sid=self._solution["interaction_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> InteractionChannelInstance:
"""
Asynchronous coroutine to fetch the InteractionChannelInstance
:returns: The fetched InteractionChannelInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return InteractionChannelInstance(
self._version,
payload,
interaction_sid=self._solution["interaction_sid"],
sid=self._solution["sid"],
)
def update(
self,
status: "InteractionChannelInstance.UpdateChannelStatus",
routing: Union[object, object] = values.unset,
) -> InteractionChannelInstance:
"""
Update the InteractionChannelInstance
:param status:
:param routing: It changes the state of associated tasks. Routing status is required, When the channel status is set to `inactive`. Allowed Value for routing status is `closed`. Otherwise Optional, if not specified, all tasks will be set to `wrapping`.
:returns: The updated InteractionChannelInstance
"""
data = values.of(
{
"Status": status,
"Routing": serialize.object(routing),
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return InteractionChannelInstance(
self._version,
payload,
interaction_sid=self._solution["interaction_sid"],
sid=self._solution["sid"],
)
async def update_async(
self,
status: "InteractionChannelInstance.UpdateChannelStatus",
routing: Union[object, object] = values.unset,
) -> InteractionChannelInstance:
"""
Asynchronous coroutine to update the InteractionChannelInstance
:param status:
:param routing: It changes the state of associated tasks. Routing status is required, When the channel status is set to `inactive`. Allowed Value for routing status is `closed`. Otherwise Optional, if not specified, all tasks will be set to `wrapping`.
:returns: The updated InteractionChannelInstance
"""
data = values.of(
{
"Status": status,
"Routing": serialize.object(routing),
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return InteractionChannelInstance(
self._version,
payload,
interaction_sid=self._solution["interaction_sid"],
sid=self._solution["sid"],
)
@property
def invites(self) -> InteractionChannelInviteList:
"""
Access the invites
"""
if self._invites is None:
self._invites = InteractionChannelInviteList(
self._version,
self._solution["interaction_sid"],
self._solution["sid"],
)
return self._invites
@property
def participants(self) -> InteractionChannelParticipantList:
"""
Access the participants
"""
if self._participants is None:
self._participants = InteractionChannelParticipantList(
self._version,
self._solution["interaction_sid"],
self._solution["sid"],
)
return self._participants
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.FlexApi.V1.InteractionChannelContext {}>".format(context)
class InteractionChannelPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> InteractionChannelInstance:
"""
Build an instance of InteractionChannelInstance
:param payload: Payload response from the API
"""
return InteractionChannelInstance(
self._version, payload, interaction_sid=self._solution["interaction_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InteractionChannelPage>"
class InteractionChannelList(ListResource):
def __init__(self, version: Version, interaction_sid: str):
"""
Initialize the InteractionChannelList
:param version: Version that contains the resource
:param interaction_sid: The unique string created by Twilio to identify an Interaction resource, prefixed with KD.
"""
super().__init__(version)
# Path Solution
self._solution = {
"interaction_sid": interaction_sid,
}
self._uri = "/Interactions/{interaction_sid}/Channels".format(**self._solution)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[InteractionChannelInstance]:
"""
Streams InteractionChannelInstance 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[InteractionChannelInstance]:
"""
Asynchronously streams InteractionChannelInstance 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[InteractionChannelInstance]:
"""
Lists InteractionChannelInstance 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[InteractionChannelInstance]:
"""
Asynchronously lists InteractionChannelInstance 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,
) -> InteractionChannelPage:
"""
Retrieve a single page of InteractionChannelInstance 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 InteractionChannelInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return InteractionChannelPage(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,
) -> InteractionChannelPage:
"""
Asynchronously retrieve a single page of InteractionChannelInstance 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 InteractionChannelInstance
"""
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 InteractionChannelPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> InteractionChannelPage:
"""
Retrieve a specific page of InteractionChannelInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InteractionChannelInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return InteractionChannelPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> InteractionChannelPage:
"""
Asynchronously retrieve a specific page of InteractionChannelInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InteractionChannelInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return InteractionChannelPage(self._version, response, self._solution)
def get(self, sid: str) -> InteractionChannelContext:
"""
Constructs a InteractionChannelContext
:param sid: The unique string created by Twilio to identify an Interaction Channel resource, prefixed with UO.
"""
return InteractionChannelContext(
self._version, interaction_sid=self._solution["interaction_sid"], sid=sid
)
def __call__(self, sid: str) -> InteractionChannelContext:
"""
Constructs a InteractionChannelContext
:param sid: The unique string created by Twilio to identify an Interaction Channel resource, prefixed with UO.
"""
return InteractionChannelContext(
self._version, interaction_sid=self._solution["interaction_sid"], sid=sid
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InteractionChannelList>"
@@ -0,0 +1,354 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
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, Iterator, AsyncIterator
from twilio.base import serialize, 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 InteractionChannelInviteInstance(InstanceResource):
"""
:ivar sid: The unique string created by Twilio to identify an Interaction Channel Invite resource.
:ivar interaction_sid: The Interaction SID for this Channel.
:ivar channel_sid: The Channel SID for this Invite.
:ivar routing: A JSON object representing the routing rules for the Interaction Channel. See [Outbound SMS Example](https://www.twilio.com/docs/flex/developer/conversations/interactions-api/interactions#agent-initiated-outbound-interactions) for an example Routing object. The Interactions resource uses TaskRouter for all routing functionality. All attributes in the Routing object on your Interaction request body are added “as is” to the task. For a list of known attributes consumed by the Flex UI and/or Flex Insights, see [Known Task Attributes](https://www.twilio.com/docs/flex/developer/conversations/interactions-api#task-attributes).
:ivar url:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
interaction_sid: str,
channel_sid: str,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.interaction_sid: Optional[str] = payload.get("interaction_sid")
self.channel_sid: Optional[str] = payload.get("channel_sid")
self.routing: Optional[Dict[str, object]] = payload.get("routing")
self.url: Optional[str] = payload.get("url")
self._solution = {
"interaction_sid": interaction_sid,
"channel_sid": channel_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.FlexApi.V1.InteractionChannelInviteInstance {}>".format(context)
class InteractionChannelInvitePage(Page):
def get_instance(self, payload: Dict[str, Any]) -> InteractionChannelInviteInstance:
"""
Build an instance of InteractionChannelInviteInstance
:param payload: Payload response from the API
"""
return InteractionChannelInviteInstance(
self._version,
payload,
interaction_sid=self._solution["interaction_sid"],
channel_sid=self._solution["channel_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InteractionChannelInvitePage>"
class InteractionChannelInviteList(ListResource):
def __init__(self, version: Version, interaction_sid: str, channel_sid: str):
"""
Initialize the InteractionChannelInviteList
:param version: Version that contains the resource
:param interaction_sid: The Interaction SID for this Channel.
:param channel_sid: The Channel SID for this Participant.
"""
super().__init__(version)
# Path Solution
self._solution = {
"interaction_sid": interaction_sid,
"channel_sid": channel_sid,
}
self._uri = (
"/Interactions/{interaction_sid}/Channels/{channel_sid}/Invites".format(
**self._solution
)
)
def create(self, routing: object) -> InteractionChannelInviteInstance:
"""
Create the InteractionChannelInviteInstance
:param routing: The Interaction's routing logic.
:returns: The created InteractionChannelInviteInstance
"""
data = values.of(
{
"Routing": serialize.object(routing),
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return InteractionChannelInviteInstance(
self._version,
payload,
interaction_sid=self._solution["interaction_sid"],
channel_sid=self._solution["channel_sid"],
)
async def create_async(self, routing: object) -> InteractionChannelInviteInstance:
"""
Asynchronously create the InteractionChannelInviteInstance
:param routing: The Interaction's routing logic.
:returns: The created InteractionChannelInviteInstance
"""
data = values.of(
{
"Routing": serialize.object(routing),
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return InteractionChannelInviteInstance(
self._version,
payload,
interaction_sid=self._solution["interaction_sid"],
channel_sid=self._solution["channel_sid"],
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[InteractionChannelInviteInstance]:
"""
Streams InteractionChannelInviteInstance 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[InteractionChannelInviteInstance]:
"""
Asynchronously streams InteractionChannelInviteInstance 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[InteractionChannelInviteInstance]:
"""
Lists InteractionChannelInviteInstance 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[InteractionChannelInviteInstance]:
"""
Asynchronously lists InteractionChannelInviteInstance 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,
) -> InteractionChannelInvitePage:
"""
Retrieve a single page of InteractionChannelInviteInstance 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 InteractionChannelInviteInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return InteractionChannelInvitePage(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,
) -> InteractionChannelInvitePage:
"""
Asynchronously retrieve a single page of InteractionChannelInviteInstance 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 InteractionChannelInviteInstance
"""
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 InteractionChannelInvitePage(self._version, response, self._solution)
def get_page(self, target_url: str) -> InteractionChannelInvitePage:
"""
Retrieve a specific page of InteractionChannelInviteInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InteractionChannelInviteInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return InteractionChannelInvitePage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> InteractionChannelInvitePage:
"""
Asynchronously retrieve a specific page of InteractionChannelInviteInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InteractionChannelInviteInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return InteractionChannelInvitePage(self._version, response, self._solution)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InteractionChannelInviteList>"
@@ -0,0 +1,560 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
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, Iterator, AsyncIterator
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
from twilio.base.page import Page
class InteractionChannelParticipantInstance(InstanceResource):
class Status(object):
CLOSED = "closed"
WRAPUP = "wrapup"
class Type(object):
SUPERVISOR = "supervisor"
CUSTOMER = "customer"
EXTERNAL = "external"
AGENT = "agent"
UNKNOWN = "unknown"
"""
:ivar sid: The unique string created by Twilio to identify an Interaction Channel Participant resource.
:ivar type:
:ivar interaction_sid: The Interaction Sid for this channel.
:ivar channel_sid: The Channel Sid for this Participant.
:ivar url:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
interaction_sid: str,
channel_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.type: Optional["InteractionChannelParticipantInstance.Type"] = payload.get(
"type"
)
self.interaction_sid: Optional[str] = payload.get("interaction_sid")
self.channel_sid: Optional[str] = payload.get("channel_sid")
self.url: Optional[str] = payload.get("url")
self._solution = {
"interaction_sid": interaction_sid,
"channel_sid": channel_sid,
"sid": sid or self.sid,
}
self._context: Optional[InteractionChannelParticipantContext] = None
@property
def _proxy(self) -> "InteractionChannelParticipantContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: InteractionChannelParticipantContext for this InteractionChannelParticipantInstance
"""
if self._context is None:
self._context = InteractionChannelParticipantContext(
self._version,
interaction_sid=self._solution["interaction_sid"],
channel_sid=self._solution["channel_sid"],
sid=self._solution["sid"],
)
return self._context
def update(
self, status: "InteractionChannelParticipantInstance.Status"
) -> "InteractionChannelParticipantInstance":
"""
Update the InteractionChannelParticipantInstance
:param status:
:returns: The updated InteractionChannelParticipantInstance
"""
return self._proxy.update(
status=status,
)
async def update_async(
self, status: "InteractionChannelParticipantInstance.Status"
) -> "InteractionChannelParticipantInstance":
"""
Asynchronous coroutine to update the InteractionChannelParticipantInstance
:param status:
:returns: The updated InteractionChannelParticipantInstance
"""
return await self._proxy.update_async(
status=status,
)
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.FlexApi.V1.InteractionChannelParticipantInstance {}>".format(
context
)
class InteractionChannelParticipantContext(InstanceContext):
def __init__(
self, version: Version, interaction_sid: str, channel_sid: str, sid: str
):
"""
Initialize the InteractionChannelParticipantContext
:param version: Version that contains the resource
:param interaction_sid: The Interaction Sid for this channel.
:param channel_sid: The Channel Sid for this Participant.
:param sid: The unique string created by Twilio to identify an Interaction Channel resource.
"""
super().__init__(version)
# Path Solution
self._solution = {
"interaction_sid": interaction_sid,
"channel_sid": channel_sid,
"sid": sid,
}
self._uri = "/Interactions/{interaction_sid}/Channels/{channel_sid}/Participants/{sid}".format(
**self._solution
)
def update(
self, status: "InteractionChannelParticipantInstance.Status"
) -> InteractionChannelParticipantInstance:
"""
Update the InteractionChannelParticipantInstance
:param status:
:returns: The updated InteractionChannelParticipantInstance
"""
data = values.of(
{
"Status": status,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return InteractionChannelParticipantInstance(
self._version,
payload,
interaction_sid=self._solution["interaction_sid"],
channel_sid=self._solution["channel_sid"],
sid=self._solution["sid"],
)
async def update_async(
self, status: "InteractionChannelParticipantInstance.Status"
) -> InteractionChannelParticipantInstance:
"""
Asynchronous coroutine to update the InteractionChannelParticipantInstance
:param status:
:returns: The updated InteractionChannelParticipantInstance
"""
data = values.of(
{
"Status": status,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return InteractionChannelParticipantInstance(
self._version,
payload,
interaction_sid=self._solution["interaction_sid"],
channel_sid=self._solution["channel_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.FlexApi.V1.InteractionChannelParticipantContext {}>".format(
context
)
class InteractionChannelParticipantPage(Page):
def get_instance(
self, payload: Dict[str, Any]
) -> InteractionChannelParticipantInstance:
"""
Build an instance of InteractionChannelParticipantInstance
:param payload: Payload response from the API
"""
return InteractionChannelParticipantInstance(
self._version,
payload,
interaction_sid=self._solution["interaction_sid"],
channel_sid=self._solution["channel_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InteractionChannelParticipantPage>"
class InteractionChannelParticipantList(ListResource):
def __init__(self, version: Version, interaction_sid: str, channel_sid: str):
"""
Initialize the InteractionChannelParticipantList
:param version: Version that contains the resource
:param interaction_sid: The Interaction Sid for this channel.
:param channel_sid: The Channel Sid for this Participant.
"""
super().__init__(version)
# Path Solution
self._solution = {
"interaction_sid": interaction_sid,
"channel_sid": channel_sid,
}
self._uri = "/Interactions/{interaction_sid}/Channels/{channel_sid}/Participants".format(
**self._solution
)
def create(
self,
type: "InteractionChannelParticipantInstance.Type",
media_properties: object,
) -> InteractionChannelParticipantInstance:
"""
Create the InteractionChannelParticipantInstance
:param type:
:param media_properties: JSON representing the Media Properties for the new Participant.
:returns: The created InteractionChannelParticipantInstance
"""
data = values.of(
{
"Type": type,
"MediaProperties": serialize.object(media_properties),
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return InteractionChannelParticipantInstance(
self._version,
payload,
interaction_sid=self._solution["interaction_sid"],
channel_sid=self._solution["channel_sid"],
)
async def create_async(
self,
type: "InteractionChannelParticipantInstance.Type",
media_properties: object,
) -> InteractionChannelParticipantInstance:
"""
Asynchronously create the InteractionChannelParticipantInstance
:param type:
:param media_properties: JSON representing the Media Properties for the new Participant.
:returns: The created InteractionChannelParticipantInstance
"""
data = values.of(
{
"Type": type,
"MediaProperties": serialize.object(media_properties),
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return InteractionChannelParticipantInstance(
self._version,
payload,
interaction_sid=self._solution["interaction_sid"],
channel_sid=self._solution["channel_sid"],
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[InteractionChannelParticipantInstance]:
"""
Streams InteractionChannelParticipantInstance 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[InteractionChannelParticipantInstance]:
"""
Asynchronously streams InteractionChannelParticipantInstance 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[InteractionChannelParticipantInstance]:
"""
Lists InteractionChannelParticipantInstance 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[InteractionChannelParticipantInstance]:
"""
Asynchronously lists InteractionChannelParticipantInstance 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,
) -> InteractionChannelParticipantPage:
"""
Retrieve a single page of InteractionChannelParticipantInstance 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 InteractionChannelParticipantInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return InteractionChannelParticipantPage(
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,
) -> InteractionChannelParticipantPage:
"""
Asynchronously retrieve a single page of InteractionChannelParticipantInstance 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 InteractionChannelParticipantInstance
"""
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 InteractionChannelParticipantPage(
self._version, response, self._solution
)
def get_page(self, target_url: str) -> InteractionChannelParticipantPage:
"""
Retrieve a specific page of InteractionChannelParticipantInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InteractionChannelParticipantInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return InteractionChannelParticipantPage(
self._version, response, self._solution
)
async def get_page_async(
self, target_url: str
) -> InteractionChannelParticipantPage:
"""
Asynchronously retrieve a specific page of InteractionChannelParticipantInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InteractionChannelParticipantInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return InteractionChannelParticipantPage(
self._version, response, self._solution
)
def get(self, sid: str) -> InteractionChannelParticipantContext:
"""
Constructs a InteractionChannelParticipantContext
:param sid: The unique string created by Twilio to identify an Interaction Channel resource.
"""
return InteractionChannelParticipantContext(
self._version,
interaction_sid=self._solution["interaction_sid"],
channel_sid=self._solution["channel_sid"],
sid=sid,
)
def __call__(self, sid: str) -> InteractionChannelParticipantContext:
"""
Constructs a InteractionChannelParticipantContext
:param sid: The unique string created by Twilio to identify an Interaction Channel resource.
"""
return InteractionChannelParticipantContext(
self._version,
interaction_sid=self._solution["interaction_sid"],
channel_sid=self._solution["channel_sid"],
sid=sid,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.InteractionChannelParticipantList>"
@@ -0,0 +1,616 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
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 WebChannelInstance(InstanceResource):
class ChatStatus(object):
INACTIVE = "inactive"
"""
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the WebChannel resource and owns this Workflow.
:ivar flex_flow_sid: The SID of the Flex Flow.
:ivar sid: The unique string that we created to identify the WebChannel resource.
:ivar url: The absolute URL of the WebChannel resource.
: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.
"""
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.flex_flow_sid: Optional[str] = payload.get("flex_flow_sid")
self.sid: Optional[str] = payload.get("sid")
self.url: Optional[str] = payload.get("url")
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 = {
"sid": sid or self.sid,
}
self._context: Optional[WebChannelContext] = None
@property
def _proxy(self) -> "WebChannelContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: WebChannelContext for this WebChannelInstance
"""
if self._context is None:
self._context = WebChannelContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the WebChannelInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the WebChannelInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "WebChannelInstance":
"""
Fetch the WebChannelInstance
:returns: The fetched WebChannelInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "WebChannelInstance":
"""
Asynchronous coroutine to fetch the WebChannelInstance
:returns: The fetched WebChannelInstance
"""
return await self._proxy.fetch_async()
def update(
self,
chat_status: Union["WebChannelInstance.ChatStatus", object] = values.unset,
post_engagement_data: Union[str, object] = values.unset,
) -> "WebChannelInstance":
"""
Update the WebChannelInstance
:param chat_status:
:param post_engagement_data: The post-engagement data.
:returns: The updated WebChannelInstance
"""
return self._proxy.update(
chat_status=chat_status,
post_engagement_data=post_engagement_data,
)
async def update_async(
self,
chat_status: Union["WebChannelInstance.ChatStatus", object] = values.unset,
post_engagement_data: Union[str, object] = values.unset,
) -> "WebChannelInstance":
"""
Asynchronous coroutine to update the WebChannelInstance
:param chat_status:
:param post_engagement_data: The post-engagement data.
:returns: The updated WebChannelInstance
"""
return await self._proxy.update_async(
chat_status=chat_status,
post_engagement_data=post_engagement_data,
)
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.FlexApi.V1.WebChannelInstance {}>".format(context)
class WebChannelContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the WebChannelContext
:param version: Version that contains the resource
:param sid: The SID of the WebChannel resource to update.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/WebChannels/{sid}".format(**self._solution)
def delete(self) -> bool:
"""
Deletes the WebChannelInstance
: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 WebChannelInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> WebChannelInstance:
"""
Fetch the WebChannelInstance
:returns: The fetched WebChannelInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return WebChannelInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> WebChannelInstance:
"""
Asynchronous coroutine to fetch the WebChannelInstance
:returns: The fetched WebChannelInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return WebChannelInstance(
self._version,
payload,
sid=self._solution["sid"],
)
def update(
self,
chat_status: Union["WebChannelInstance.ChatStatus", object] = values.unset,
post_engagement_data: Union[str, object] = values.unset,
) -> WebChannelInstance:
"""
Update the WebChannelInstance
:param chat_status:
:param post_engagement_data: The post-engagement data.
:returns: The updated WebChannelInstance
"""
data = values.of(
{
"ChatStatus": chat_status,
"PostEngagementData": post_engagement_data,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return WebChannelInstance(self._version, payload, sid=self._solution["sid"])
async def update_async(
self,
chat_status: Union["WebChannelInstance.ChatStatus", object] = values.unset,
post_engagement_data: Union[str, object] = values.unset,
) -> WebChannelInstance:
"""
Asynchronous coroutine to update the WebChannelInstance
:param chat_status:
:param post_engagement_data: The post-engagement data.
:returns: The updated WebChannelInstance
"""
data = values.of(
{
"ChatStatus": chat_status,
"PostEngagementData": post_engagement_data,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return WebChannelInstance(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.FlexApi.V1.WebChannelContext {}>".format(context)
class WebChannelPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> WebChannelInstance:
"""
Build an instance of WebChannelInstance
:param payload: Payload response from the API
"""
return WebChannelInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.WebChannelPage>"
class WebChannelList(ListResource):
def __init__(self, version: Version):
"""
Initialize the WebChannelList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/WebChannels"
def create(
self,
flex_flow_sid: str,
identity: str,
customer_friendly_name: str,
chat_friendly_name: str,
chat_unique_name: Union[str, object] = values.unset,
pre_engagement_data: Union[str, object] = values.unset,
) -> WebChannelInstance:
"""
Create the WebChannelInstance
:param flex_flow_sid: The SID of the Flex Flow.
:param identity: The chat identity.
:param customer_friendly_name: The chat participant's friendly name.
:param chat_friendly_name: The chat channel's friendly name.
:param chat_unique_name: The chat channel's unique name.
:param pre_engagement_data: The pre-engagement data.
:returns: The created WebChannelInstance
"""
data = values.of(
{
"FlexFlowSid": flex_flow_sid,
"Identity": identity,
"CustomerFriendlyName": customer_friendly_name,
"ChatFriendlyName": chat_friendly_name,
"ChatUniqueName": chat_unique_name,
"PreEngagementData": pre_engagement_data,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return WebChannelInstance(self._version, payload)
async def create_async(
self,
flex_flow_sid: str,
identity: str,
customer_friendly_name: str,
chat_friendly_name: str,
chat_unique_name: Union[str, object] = values.unset,
pre_engagement_data: Union[str, object] = values.unset,
) -> WebChannelInstance:
"""
Asynchronously create the WebChannelInstance
:param flex_flow_sid: The SID of the Flex Flow.
:param identity: The chat identity.
:param customer_friendly_name: The chat participant's friendly name.
:param chat_friendly_name: The chat channel's friendly name.
:param chat_unique_name: The chat channel's unique name.
:param pre_engagement_data: The pre-engagement data.
:returns: The created WebChannelInstance
"""
data = values.of(
{
"FlexFlowSid": flex_flow_sid,
"Identity": identity,
"CustomerFriendlyName": customer_friendly_name,
"ChatFriendlyName": chat_friendly_name,
"ChatUniqueName": chat_unique_name,
"PreEngagementData": pre_engagement_data,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return WebChannelInstance(self._version, payload)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[WebChannelInstance]:
"""
Streams WebChannelInstance 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[WebChannelInstance]:
"""
Asynchronously streams WebChannelInstance 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[WebChannelInstance]:
"""
Lists WebChannelInstance 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[WebChannelInstance]:
"""
Asynchronously lists WebChannelInstance 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,
) -> WebChannelPage:
"""
Retrieve a single page of WebChannelInstance 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 WebChannelInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return WebChannelPage(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,
) -> WebChannelPage:
"""
Asynchronously retrieve a single page of WebChannelInstance 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 WebChannelInstance
"""
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 WebChannelPage(self._version, response)
def get_page(self, target_url: str) -> WebChannelPage:
"""
Retrieve a specific page of WebChannelInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of WebChannelInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return WebChannelPage(self._version, response)
async def get_page_async(self, target_url: str) -> WebChannelPage:
"""
Asynchronously retrieve a specific page of WebChannelInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of WebChannelInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return WebChannelPage(self._version, response)
def get(self, sid: str) -> WebChannelContext:
"""
Constructs a WebChannelContext
:param sid: The SID of the WebChannel resource to update.
"""
return WebChannelContext(self._version, sid=sid)
def __call__(self, sid: str) -> WebChannelContext:
"""
Constructs a WebChannelContext
:param sid: The SID of the WebChannel resource to update.
"""
return WebChannelContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V1.WebChannelList>"
@@ -0,0 +1,42 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
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.flex_api.v2.web_channels import WebChannelsList
class V2(Version):
def __init__(self, domain: Domain):
"""
Initialize the V2 version of FlexApi
:param domain: The Twilio.flex_api domain
"""
super().__init__(domain, "v2")
self._web_channels: Optional[WebChannelsList] = None
@property
def web_channels(self) -> WebChannelsList:
if self._web_channels is None:
self._web_channels = WebChannelsList(self)
return self._web_channels
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V2>"
@@ -0,0 +1,133 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Flex
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_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
class WebChannelsInstance(InstanceResource):
"""
:ivar conversation_sid: The unique string representing the [Conversation resource](https://www.twilio.com/docs/conversations/api/conversation-resource) created.
:ivar identity: The unique string representing the User created and should be authorized to participate in the Conversation. For more details, see [User Identity & Access Tokens](https://www.twilio.com/docs/conversations/identity).
"""
def __init__(self, version: Version, payload: Dict[str, Any]):
super().__init__(version)
self.conversation_sid: Optional[str] = payload.get("conversation_sid")
self.identity: Optional[str] = payload.get("identity")
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V2.WebChannelsInstance>"
class WebChannelsList(ListResource):
def __init__(self, version: Version):
"""
Initialize the WebChannelsList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/WebChats"
def create(
self,
address_sid: str,
chat_friendly_name: Union[str, object] = values.unset,
customer_friendly_name: Union[str, object] = values.unset,
pre_engagement_data: Union[str, object] = values.unset,
) -> WebChannelsInstance:
"""
Create the WebChannelsInstance
:param address_sid: The SID of the Conversations Address. See [Address Configuration Resource](https://www.twilio.com/docs/conversations/api/address-configuration-resource) for configuration details. When a conversation is created on the Flex backend, the callback URL will be set to the corresponding Studio Flow SID or webhook URL in your address configuration.
:param chat_friendly_name: The Conversation's friendly name. See the [Conversation resource](https://www.twilio.com/docs/conversations/api/conversation-resource) for an example.
:param customer_friendly_name: The Conversation participant's friendly name. See the [Conversation Participant Resource](https://www.twilio.com/docs/conversations/api/conversation-participant-resource) for an example.
:param pre_engagement_data: The pre-engagement data.
:returns: The created WebChannelsInstance
"""
data = values.of(
{
"AddressSid": address_sid,
"ChatFriendlyName": chat_friendly_name,
"CustomerFriendlyName": customer_friendly_name,
"PreEngagementData": pre_engagement_data,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return WebChannelsInstance(self._version, payload)
async def create_async(
self,
address_sid: str,
chat_friendly_name: Union[str, object] = values.unset,
customer_friendly_name: Union[str, object] = values.unset,
pre_engagement_data: Union[str, object] = values.unset,
) -> WebChannelsInstance:
"""
Asynchronously create the WebChannelsInstance
:param address_sid: The SID of the Conversations Address. See [Address Configuration Resource](https://www.twilio.com/docs/conversations/api/address-configuration-resource) for configuration details. When a conversation is created on the Flex backend, the callback URL will be set to the corresponding Studio Flow SID or webhook URL in your address configuration.
:param chat_friendly_name: The Conversation's friendly name. See the [Conversation resource](https://www.twilio.com/docs/conversations/api/conversation-resource) for an example.
:param customer_friendly_name: The Conversation participant's friendly name. See the [Conversation Participant Resource](https://www.twilio.com/docs/conversations/api/conversation-participant-resource) for an example.
:param pre_engagement_data: The pre-engagement data.
:returns: The created WebChannelsInstance
"""
data = values.of(
{
"AddressSid": address_sid,
"ChatFriendlyName": chat_friendly_name,
"CustomerFriendlyName": customer_friendly_name,
"PreEngagementData": pre_engagement_data,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return WebChannelsInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.FlexApi.V2.WebChannelsList>"