U
    hRf/N                     @   s   d Z ddlmZ ddlmZmZmZmZmZmZm	Z	 ddl
mZmZmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lmZ G d
d deZG dd deZG dd deZG dd deZdS )a  
    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.
    )datetime)AnyDictListOptionalUnionIteratorAsyncIterator)deserialize	serializevalues)InstanceContext)InstanceResource)ListResource)Version)Pagec                       s   e Zd ZdZdeeeef ee d fddZ	e
dddd	Zedd
dZedddZd dddZd dddZedddZ  ZS )ChannelInstanceak  
    :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.
    N)versionpayloadsidc                    s   t  | |d| _|d| _|d| _|d| _|d| _|d| _t	
|d| _t	
|d| _d|p| ji| _d | _d S )	Naccount_sidflex_flow_sidr   user_sidtask_sidurldate_createddate_updated)super__init__getr   r   r   r   r   r   r
   iso8601_datetimer   r   	_solution_context)selfr   r   r   	__class__ C/tmp/pip-unpacked-wheel-74se_viw/twilio/rest/flex_api/v1/channel.pyr   %   s"     zChannelInstance.__init__ChannelContextreturnc                 C   s&   | j dkr t| j| jd d| _ | j S )z
        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
        Nr   r   )r"   r(   _versionr!   r#   r&   r&   r'   _proxy<   s    
zChannelInstance._proxyc                 C   s
   | j  S )j
        Deletes the ChannelInstance


        :returns: True if delete succeeds, False otherwise
        )r.   deleter-   r&   r&   r'   r0   K   s    zChannelInstance.deletec                    s   | j  I dH S )
        Asynchronous coroutine that deletes the ChannelInstance


        :returns: True if delete succeeds, False otherwise
        N)r.   delete_asyncr-   r&   r&   r'   r2   T   s    zChannelInstance.delete_asyncc                 C   s
   | j  S )[
        Fetch the ChannelInstance


        :returns: The fetched ChannelInstance
        )r.   fetchr-   r&   r&   r'   r4   ]   s    zChannelInstance.fetchc                    s   | j  I dH S )u
        Asynchronous coroutine to fetch the ChannelInstance


        :returns: The fetched ChannelInstance
        N)r.   fetch_asyncr-   r&   r&   r'   r6   f   s    zChannelInstance.fetch_asyncc                 C   s$   d dd | j D }d|S )f
        Provide a friendly representation

        :returns: Machine friendly representation
         c                 s   s   | ]\}}d  ||V  qdS z{}={}Nformat.0kvr&   r&   r'   	<genexpr>u   s     z+ChannelInstance.__repr__.<locals>.<genexpr>z&<Twilio.FlexApi.V1.ChannelInstance {}>joinr!   itemsr;   r#   contextr&   r&   r'   __repr__o   s    zChannelInstance.__repr__)N)__name__
__module____qualname____doc__r   r   strr   r   r   propertyr.   boolr0   r2   r4   r6   rF   __classcell__r&   r&   r$   r'   r      s     
 				r   c                       sj   e Zd Zeed fddZedddZedddZe	dd	d
Z
e	dddZedddZ  ZS )r(   )r   r   c                    s*   t  | d|i| _djf | j| _dS )z
        Initialize the ChannelContext

        :param version: Version that contains the resource
        :param sid: The SID of the Flex chat channel resource to fetch.
        r   z/Channels/{sid}N)r   r   r!   r;   _uri)r#   r   r   r$   r&   r'   r   {   s
     zChannelContext.__init__r)   c                 C   s   | j jd| jdS )r/   DELETEmethoduri)r,   r0   rO   r-   r&   r&   r'   r0      s    zChannelContext.deletec                    s   | j jd| jdI dH S )r1   rP   rQ   N)r,   r2   rO   r-   r&   r&   r'   r2      s    zChannelContext.delete_asyncc                 C   s(   | j jd| jd}t| j || jd dS )r3   GETrQ   r   r+   )r,   r4   rO   r   r!   r#   r   r&   r&   r'   r4      s    zChannelContext.fetchc                    s.   | j jd| jdI dH }t| j || jd dS )r5   rT   rQ   Nr   r+   )r,   r6   rO   r   r!   rU   r&   r&   r'   r6      s    zChannelContext.fetch_asyncc                 C   s$   d dd | j D }d|S )r7   r8   c                 s   s   | ]\}}d  ||V  qdS r9   r:   r<   r&   r&   r'   r@      s     z*ChannelContext.__repr__.<locals>.<genexpr>z%<Twilio.FlexApi.V1.ChannelContext {}>rA   rD   r&   r&   r'   rF      s    zChannelContext.__repr__)rG   rH   rI   r   rK   r   rM   r0   r2   r   r4   r6   rF   rN   r&   r&   r$   r'   r(   y   s   r(   c                   @   s2   e Zd Zeeef edddZedddZdS )ChannelPage)r   r*   c                 C   s   t | j|S )zm
        Build an instance of ChannelInstance

        :param payload: Payload response from the API
        )r   r,   rU   r&   r&   r'   get_instance   s    zChannelPage.get_instancer)   c                 C   s   dS )r7   z<Twilio.FlexApi.V1.ChannelPage>r&   r-   r&   r&   r'   rF      s    zChannelPage.__repr__N)	rG   rH   rI   r   rK   r   r   rW   rF   r&   r&   r&   r'   rV      s   rV   c                       s<  e Zd Zed fddZejejejejejejfeeeeeee	f eee	f eee	f eee	f eee	f ee
e	f edddZejejejejejejfeeeeeee	f eee	f eee	f eee	f eee	f ee
e	f edddZd%ee ee ee d
ddZd&ee ee ee d
ddZd'ee ee ee d
ddZd(ee ee ee d
ddZejejejfeee	f eee	f eee	f edddZejejejfeee	f eee	f eee	f edddZeedddZeedddZeedddZeedd d!Zed"d#d$Z  Z S ))ChannelList)r   c                    s   t  | d| _dS )zi
        Initialize the ChannelList

        :param version: Version that contains the resource

        z	/ChannelsN)r   r   rO   )r#   r   r$   r&   r'   r      s    zChannelList.__init__)r   identitychat_user_friendly_namechat_friendly_nametargetchat_unique_namepre_engagement_datar   task_attributes
long_livedr*   c                 C   sV   t |||||||||	t|
d
}t ddi}| jjd| j||d}t| j|S )a  
        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
        
ZFlexFlowSidZIdentityZChatUserFriendlyNameZChatFriendlyNameZTargetZChatUniqueNameZPreEngagementDataZTaskSidZTaskAttributesZ	LongLivedContent-Type!application/x-www-form-urlencodedPOSTrR   rS   dataheaders)r   ofr   boolean_to_stringr,   createrO   r   r#   r   rY   rZ   r[   r\   r]   r^   r   r_   r`   rf   rg   r   r&   r&   r'   rj      s*       zChannelList.createc                    s\   t |||||||||	t|
d
}t ddi}| jjd| j||dI dH }t| j|S )a  
        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
        ra   rb   rc   rd   re   N)r   rh   r   ri   r,   create_asyncrO   r   rk   r&   r&   r'   rl   &  s*       zChannelList.create_asyncN)limit	page_sizer*   c                 C   s0   | j ||}| j|d d}| j ||d S )a]  
        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
        rn   rn   rm   )r,   read_limitspagestreamr#   rm   rn   Zlimitsrq   r&   r&   r'   rr   Z  s    zChannelList.streamc                    s6   | j ||}| j|d dI dH }| j ||d S )al  
        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
        rn   ro   Nrm   )r,   rp   
page_asyncstream_asyncrs   r&   r&   r'   ru   s  s    zChannelList.stream_asyncc                 C   s   t | j||dS )a  
        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
        rm   rn   )listrr   r#   rm   rn   r&   r&   r'   rw     s    zChannelList.listc                    s$   dd | j ||dI dH 2 I dH S )a	  
        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
        c                    s   g | z3 d H W }|q6 S )Nr&   )r=   recordr&   r&   r'   
<listcomp>  s   z*ChannelList.list_async.<locals>.<listcomp>rv   N)ru   rx   r&   r&   r'   
list_async  s    
zChannelList.list_async)
page_tokenpage_numberrn   r*   c                 C   s2   t |||d}| jjd| j|d}t| j|S )as  
        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
        Z	PageTokenr   ZPageSizerT   rR   rS   params)r   rh   r,   rq   rO   rV   r#   r|   r}   rn   rf   responser&   r&   r'   rq     s    zChannelList.pagec                    s8   t |||d}| jjd| j|dI dH }t| j|S )a  
        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
        r~   rT   r   N)r   rh   r,   rt   rO   rV   r   r&   r&   r'   rt     s      zChannelList.page_async)
target_urlr*   c                 C   s   | j jjd|}t| j |S )z
        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
        rT   )r,   domaintwiliorequestrV   r#   r   r   r&   r&   r'   get_page  s    	zChannelList.get_pagec                    s$   | j jjd|I dH }t| j |S )a  
        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
        rT   N)r,   r   r   Zrequest_asyncrV   r   r&   r&   r'   get_page_async  s    	zChannelList.get_page_async)r   r*   c                 C   s   t | j|dS zv
        Constructs a ChannelContext

        :param sid: The SID of the Flex chat channel resource to fetch.
        r+   r(   r,   r#   r   r&   r&   r'   r     s    zChannelList.getc                 C   s   t | j|dS r   r   r   r&   r&   r'   __call__  s    zChannelList.__call__r)   c                 C   s   dS )r7   z<Twilio.FlexApi.V1.ChannelList>r&   r-   r&   r&   r'   rF   !  s    zChannelList.__repr__)NN)NN)NN)NN)!rG   rH   rI   r   r   r   ZunsetrK   r   objectrM   r   rj   rl   r   intr   rr   r	   ru   r   rw   r{   rV   rq   rt   r   r   r(   r   r   rF   rN   r&   r&   r$   r'   rX      s   





:





6        





rX   N)rJ   r   typingr   r   r   r   r   r   r	   Ztwilio.baser
   r   r   Ztwilio.base.instance_contextr   Ztwilio.base.instance_resourcer   Ztwilio.base.list_resourcer   Ztwilio.base.versionr   Ztwilio.base.pager   r   r(   rV   rX   r&   r&   r&   r'   <module>   s   $`Y