HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/twilio/base/__pycache__/page.cpython-310.pyc
o

-we=�@sHddlZddlmZmZmZddlmZddlmZGdd�de	�Z
dS)�N)�Any�Dict�Optional��TwilioException)�Responsec@s
eZdZdZhd�Zifdefdd�Zdd�Zdd	�Zd
d�Z	e
dedefd
d��Zde
eeffdd�Zedeefdd��Zedeefdd��Zde
eefdefdd�Zdedfdd�Zdedfdd�Zdedfdd�Zdedfdd�Zdefd d!�Zd"S)#�Pagez�
    Represents a page of records in a collection.

    A `Page` lets you iterate over its records and fetch the next and previous
    pages in the collection.
    >�end�uri�page�start�total�	num_pages�	page_size�
last_page_uri�
next_page_uri�first_page_uri�previous_page_uri�responsecCs0|�|�}||_||_||_t|�|��|_dS�N)�process_response�_version�_payload�	_solution�iter�	load_page�_records)�self�versionr�solution�payload�r!�I/home/arjun/projects/env/lib/python3.10/site-packages/twilio/base/page.py�__init__s

z
Page.__init__cCs|S)z/
        A `Page` is a valid iterator.
        r!�rr!r!r"�__iter__&sz
Page.__iter__cCs|��Sr)�nextr$r!r!r"�__next__,sz
Page.__next__cCs|�t|j��S)z8
        Returns the next record in the `Page`.
        )�get_instancer&rr$r!r!r"r&/sz	Page.next�returncCs |jdkr
td|��t�|j�S)z}
        Load a JSON response.

        :param response: The HTTP response.
        :return The JSON-loaded content.
        ��zUnable to fetch page)�status_coder�json�loads�text)�clsrr!r!r"r5s

zPage.process_responser cCsZd|vrd|dvr||ddSt|���}||j}t|�dkr)||��Std��)z�
        Parses the collection of records out of a list payload.

        :param payload: The JSON-loaded content.
        :return list: The list of records.
        �meta�key�z$Page Records can not be deserialized)�set�keys�	META_KEYS�len�popr)rr r4r1r!r!r"rBs
zPage.load_pagecC�Rd|jvrd|jdvr|jddSd|jvr'|jdr'|jj�|jd�SdS)z`
        :return str: Returns a link to the previous_page_url or None if doesn't exist.
        r0�previous_page_urlrN�rr�domain�absolute_urlr$r!r!r"r9Ss
zPage.previous_page_urlcCr8)z\
        :return str: Returns a link to the next_page_url or None if doesn't exist.
        r0�
next_page_urlrNr:r$r!r!r"r=as
zPage.next_page_urlcCstd��)z�
        :param dict payload: A JSON-loaded representation of an instance record.
        :return: A rich, resource-dependent object.
        z<Page.get_instance() must be implemented in the derived classr)rr r!r!r"r(ms�zPage.get_instancecC�6|jsdS|jjj�d|j�}t|�}||j||j�S)zR
        Return the `Page` after this one.
        :return The next page.
        N�GET)r=rr;�twilio�request�typer�rrr/r!r!r"�	next_pagev�
zPage.next_pagec��>�|jsdS|jjj�d|j�IdH}t|�}||j||j�S)za
        Asynchronously return the `Page` after this one.
        :return The next page.
        Nr?)r=rr;r@�
request_asyncrBrrCr!r!r"�next_page_async���

�zPage.next_page_asynccCr>)zW
        Return the `Page` before this one.
        :return The previous page.
        Nr?)r9rr;r@rArBrrCr!r!r"�
previous_page�rEzPage.previous_pagec�rF)zf
        Asynchronously return the `Page` before this one.
        :return The previous page.
        Nr?)r9rr;r@rGrBrrCr!r!r"�previous_page_async�rIzPage.previous_page_asynccCsdS)Nz<Page>r!r$r!r!r"�__repr__�sz
Page.__repr__N)�__name__�
__module__�__qualname__�__doc__r5rr#r%r'r&�classmethodrrr�strr�propertyrr9r=r(rDrHrJrKrLr!r!r!r"rs(
	r)r,�typingrrr�twilio.base.exceptionsr�twilio.http.responser�objectrr!r!r!r"�<module>s