
    d{i!                     F    d dl mZmZmZ d dlmZ d dlmZ  G d de      Zy)    )OptionalAnyDict)TwilioException)Pagec            
       R    e Zd ZdZ	 	 ddedeeeef      deeeef      f fdZe	dee   fd       Z
e	dee   fd       Ze	dee   fd	       Ze	dee   fd
       Zdee   ded    fdZdee   ded    fdZded    fdZded    fdZded    fdZded    fdZdefdZ xZS )TokenPaginationa  
    Represents a page of records using token-based pagination.

    Token-based pagination uses next_token and previous_token instead of
    page numbers to navigate through results.

    Example expected response format with token metadata:
    {
      "meta": {
        "key": "items",
        "pageSize": 50,
        "nextToken": "abc123",
        "previousToken": "xyz789"
      },
      "items": [
        { "id": 1, "name": "Item 1" },
        { "id": 2, "name": "Item 2" }
      ]
    }
    uriparamssolutionc                 X    t         |   |||       || _        ||| _        y i | _        y )N)super__init___uri_params)selfversionresponser
   r   r   	__class__s         Z/home/sas/my/fyp/ringai/.venv/lib/python3.12/site-packages/twilio/base/token_pagination.pyr   zTokenPagination.__init__   s/     	(H5	!'!3v    returnc                 f    d| j                   v r#d| j                   d   v r| j                   d   d   S y)z^
        :return str: Returns the key that identifies the collection in the response.
        metakeyN_payloadr   s    r   r   zTokenPagination.key)   s7    
 T]]"uf0E'E==(//r   c                 f    d| j                   v r#d| j                   d   v r| j                   d   d   S y)zN
        :return int: Returns the page size or None if doesn't exist.
        r   pageSizeNr   r   s    r   	page_sizezTokenPagination.page_size2   s7    
 T]]"zT]]65J'J==(44r   c                 f    d| j                   v r#d| j                   d   v r| j                   d   d   S y)z^
        :return str: Returns the next_token for pagination or None if doesn't exist.
        r   	nextTokenNr   r   s    r   
next_tokenzTokenPagination.next_token;   s7    
 T]]"{dmmF6K'K==(55r   c                 f    d| j                   v r#d| j                   d   v r| j                   d   d   S y)zb
        :return str: Returns the previous_token for pagination or None if doesn't exist.
        r   previousTokenNr   r   s    r   previous_tokenzTokenPagination.previous_tokenD   s7    
 T]]"$--:O'O==(99r   tokenc                 6   |sy| j                   st        d      || j                  d<   | j                  j	                  d| j                   | j                        }t        |       } || j                  || j                   | j                  | j                        S )z
        Internal helper to fetch a page using a given token.

        :param token: The pagination token to use.
        :return: The page or None if no token exists.
        N)URI must be provided for token pagination	pageTokenGETmethodr
   r   r   r   r   _versionpagetype	_solutionr   r(   r   clss       r   	_get_pagezTokenPagination._get_pageM   sz     yy!"MNN$)[!==%%U		$,,%W4j4==(DIIt||T^^TTr   c                 >  K   |sy| j                   st        d      || j                  d<   | j                  j	                  d| j                   | j                        }t        |       } || j                  || j                   | j                  | j                        S w)z
        Internal async helper to fetch a page using a given token.

        :param token: The pagination token to use.
        :return: The page or None if no token exists.
        Nr*   r+   r,   r-   r/   r4   s       r   _get_page_asynczTokenPagination._get_page_async`   s      yy!"MNN %*[!==%%U		$,,%W4j4==(DIIt||T^^TTs   BBc                 8    | j                  | j                        S )z
        Return the next page using token-based pagination.
        Makes a request to the same URI with pageToken set to nextToken.

        :return: The next page or None if no next token exists.
        )r6   r$   r   s    r   	next_pagezTokenPagination.next_pageu   s     ~~doo..r   c                 T   K   | j                  | j                         d{   S 7 w)z
        Asynchronously return the next page using token-based pagination.
        Makes a request to the same URI with pageToken set to nextToken.

        :return: The next page or None if no next token exists.
        N)r8   r$   r   s    r   next_page_asynczTokenPagination.next_page_async~   s#      ))$//::::   (&(c                 8    | j                  | j                        S )z
        Return the previous page using token-based pagination.
        Makes a request to the same URI with pageToken set to previousToken.

        :return: The previous page or None if no previous token exists.
        )r6   r'   r   s    r   previous_pagezTokenPagination.previous_page   s     ~~d1122r   c                 T   K   | j                  | j                         d{   S 7 w)z
        Asynchronously return the previous page using token-based pagination.
        Makes a request to the same URI with pageToken set to previousToken.

        :return: The previous page or None if no previous token exists.
        N)r8   r'   r   s    r   previous_page_asyncz#TokenPagination.previous_page_async   s%      ))$*=*=>>>>r=   c                      y)Nz<TokenPagination> r   s    r   __repr__zTokenPagination.__repr__   s    "r   )NN)__name__
__module____qualname____doc__strr   r   r   r   propertyr   intr!   r$   r'   r6   r8   r:   r<   r?   rA   rD   __classcell__)r   s   @r   r	   r	      s_   4 ,0-1
< 	
<
 c3h(
< 4S>*
< Xc]   8C=   HSM     Ux} U:K1L U&Uc]U	#	$U*/8$56 /;x0A'B ;3x(9: 3?84E+F ?## #r   r	   N)	typingr   r   r   twilio.base.exceptionsr   twilio.base.pager   r	   rC   r   r   <module>rP      s    & & 2 !S#d S#r   