o
    #`^h)  ã                   @   sx   d Z ddlmZmZmZ ddlZddlmZ G dd„ deeƒƒZG dd„ deƒZ	G d	d
„ d
eeƒƒZ
G dd„ de
ƒZdS )zlinebot.http_client module.é    )ÚABCMetaÚabstractmethodÚabstractpropertyN)Úwith_metaclassc                   @   sX   e Zd ZdZdZefdd„Zeddd„ƒZedd	d
„ƒZeddd„ƒZ	eddd„ƒZ
dS )Ú
HttpClientz$Abstract Base Classes of HttpClient.é   c                 C   ó
   || _ dS )aŒ  __init__ method.

        :param timeout: (optional) How long to wait for the server
            to send data before giving up, as a float,
            or a (connect timeout, read timeout) float tuple.
            Default is :py:attr:`DEFAULT_TIMEOUT`
        :type timeout: float | tuple(float, float)
        :rtype: T <= :py:class:`HttpResponse`
        :return: HttpResponse instance
        N)Útimeout©Úselfr	   © r   úQ/home/air/shanriGPT/back/venv/lib/python3.10/site-packages/linebot/http_client.pyÚ__init__   s   
zHttpClient.__init__NFc                 C   ó   t ‚)a^  GET request.

        :param str url: Request url
        :param dict headers: (optional) Request headers
        :param dict params: (optional) Request query parameter
        :param bool stream: (optional) get content as stream
        :param timeout: (optional), How long to wait for the server
            to send data before giving up, as a float,
            or a (connect timeout, read timeout) float tuple.
            Default is :py:attr:`self.timeout`
        :type timeout: float | tuple(float, float)
        :rtype: T <= :py:class:`HttpResponse`
        :return: HttpResponse instance
        ©ÚNotImplementedError)r   ÚurlÚheadersÚparamsÚstreamr	   r   r   r   Úget*   s   zHttpClient.getc                 C   r   )a>  POST request.

        :param str url: Request url
        :param dict headers: (optional) Request headers
        :param data: (optional) Dictionary, bytes, or file-like object to send in the body
        :param timeout: (optional), How long to wait for the server
            to send data before giving up, as a float,
            or a (connect timeout, read timeout) float tuple.
            Default is :py:attr:`self.timeout`
        :type timeout: float | tuple(float, float)
        :rtype: T <= :py:class:`HttpResponse`
        :return: HttpResponse instance
        r   ©r   r   r   Údatar	   r   r   r   Úpost<   ó   zHttpClient.postc                 C   r   )a@  DELETE request.

        :param str url: Request url
        :param dict headers: (optional) Request headers
        :param data: (optional) Dictionary, bytes, or file-like object to send in the body
        :param timeout: (optional), How long to wait for the server
            to send data before giving up, as a float,
            or a (connect timeout, read timeout) float tuple.
            Default is :py:attr:`self.timeout`
        :type timeout: float | tuple(float, float)
        :rtype: T <= :py:class:`HttpResponse`
        :return: HttpResponse instance
        r   r   r   r   r   ÚdeleteM   r   zHttpClient.deletec                 C   r   )áH  PUT request.

        :param str url: Request url
        :param dict headers: (optional) Request headers
        :param data: (optional) Dictionary, bytes, or file-like object to send in the body
        :param timeout: (optional), How long to wait for the server
            to send data before giving up, as a float,
            or a (connect timeout, read timeout) float tuple.
            Default is :py:attr:`self.timeout`
        :type timeout: float | tuple(float, float)
        :rtype: :py:class:`RequestsHttpResponse`
        :return: RequestsHttpResponse instance
        r   r   r   r   r   Úput^   r   zHttpClient.put©NNFN©NNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚDEFAULT_TIMEOUTr   r   r   r   r   r   r   r   r   r   r      s    r   c                       sN   e Zd ZdZejf‡ fdd„	Zddd„Zddd	„Zdd
d„Z	ddd„Z
‡  ZS )ÚRequestsHttpClientz#HttpClient implemented by requests.c                    s   t t| ƒ |¡ dS )a7  __init__ method.

        :param timeout: (optional) How long to wait for the server
            to send data before giving up, as a float,
            or a (connect timeout, read timeout) float tuple.
            Default is :py:attr:`DEFAULT_TIMEOUT`
        :type timeout: float | tuple(float, float)
        N)Úsuperr%   r   r
   ©Ú	__class__r   r   r   s   s   	zRequestsHttpClient.__init__NFc                 C   s*   |du r| j }tj|||||d}t|ƒS )ai  GET request.

        :param str url: Request url
        :param dict headers: (optional) Request headers
        :param dict params: (optional) Request query parameter
        :param bool stream: (optional) get content as stream
        :param timeout: (optional), How long to wait for the server
            to send data before giving up, as a float,
            or a (connect timeout, read timeout) float tuple.
            Default is :py:attr:`self.timeout`
        :type timeout: float | tuple(float, float)
        :rtype: :py:class:`RequestsHttpResponse`
        :return: RequestsHttpResponse instance
        N)r   r   r   r	   )r	   Úrequestsr   ÚRequestsHttpResponse)r   r   r   r   r   r	   Úresponser   r   r   r   ~   s   
ÿzRequestsHttpClient.getc                 C   ó(   |du r| j }tj||||d}t|ƒS )aI  POST request.

        :param str url: Request url
        :param dict headers: (optional) Request headers
        :param data: (optional) Dictionary, bytes, or file-like object to send in the body
        :param timeout: (optional), How long to wait for the server
            to send data before giving up, as a float,
            or a (connect timeout, read timeout) float tuple.
            Default is :py:attr:`self.timeout`
        :type timeout: float | tuple(float, float)
        :rtype: :py:class:`RequestsHttpResponse`
        :return: RequestsHttpResponse instance
        N©r   r   r	   )r	   r)   r   r*   ©r   r   r   r   r	   r+   r   r   r   r   –   ó   ÿzRequestsHttpClient.postc                 C   r,   )aK  DELETE request.

        :param str url: Request url
        :param dict headers: (optional) Request headers
        :param data: (optional) Dictionary, bytes, or file-like object to send in the body
        :param timeout: (optional), How long to wait for the server
            to send data before giving up, as a float,
            or a (connect timeout, read timeout) float tuple.
            Default is :py:attr:`self.timeout`
        :type timeout: float | tuple(float, float)
        :rtype: :py:class:`RequestsHttpResponse`
        :return: RequestsHttpResponse instance
        Nr-   )r	   r)   r   r*   r.   r   r   r   r   ­   r/   zRequestsHttpClient.deletec                 C   r,   )r   Nr-   )r	   r)   r   r*   r.   r   r   r   r   Ä   r/   zRequestsHttpClient.putr   r   )r    r!   r"   r#   r   r$   r   r   r   r   r   Ú__classcell__r   r   r'   r   r%   p   s    


r%   c                   @   sZ   e Zd ZdZedd„ ƒZedd„ ƒZedd„ ƒZedd	„ ƒZed
d„ ƒZ	e
ddd„ƒZdS )ÚHttpResponsezHttpResponse.c                 C   r   ©zGet status code.r   ©r   r   r   r   Ústatus_codeß   ó   zHttpResponse.status_codec                 C   r   )zGet headers.r   r3   r   r   r   r   ä   r5   zHttpResponse.headersc                 C   r   ©z"Get response body as text-decoded.r   r3   r   r   r   Útexté   r5   zHttpResponse.textc                 C   r   ©zGet response body as binary.r   r3   r   r   r   Úcontentî   r5   zHttpResponse.contentc                 C   r   ©z"Get response body as json-decoded.r   r3   r   r   r   Újsonó   r5   zHttpResponse.jsoné   Fc                 C   r   )ú|Get response body as iterator content (stream).

        :param int chunk_size:
        :param bool decode_unicode:
        r   ©r   Ú
chunk_sizeÚdecode_unicoder   r   r   Úiter_contentø   s   zHttpResponse.iter_contentN©r<   F)r    r!   r"   r#   r   r4   r   r7   r9   r;   r   rA   r   r   r   r   r1   Ü   s    




r1   c                   @   s^   e Zd ZdZdd„ Zedd„ ƒZedd„ ƒZedd	„ ƒZed
d„ ƒZ	edd„ ƒZ
ddd„ZdS )r*   z4HttpResponse implemented by requests lib's response.c                 C   r   )zK__init__ method.

        :param response: requests lib's response
        N)r+   )r   r+   r   r   r   r     s   
zRequestsHttpResponse.__init__c                 C   ó   | j jS r2   )r+   r4   r3   r   r   r   r4     ó   z RequestsHttpResponse.status_codec                 C   rC   )zUGet headers.

        :rtype :py:class:`requests.models.CaseInsensitiveDict`
        )r+   r   r3   r   r   r   r     s   zRequestsHttpResponse.headersc                 C   rC   r6   )r+   r7   r3   r   r   r   r7     rD   zRequestsHttpResponse.textc                 C   rC   r8   )r+   r9   r3   r   r   r   r9     rD   zRequestsHttpResponse.contentc                 C   s
   | j  ¡ S r:   )r+   r;   r3   r   r   r   r;   #  s   
zRequestsHttpResponse.jsonr<   Fc                 C   s   | j j||dS )r=   )r?   r@   )r+   rA   r>   r   r   r   rA   (  s   z!RequestsHttpResponse.iter_contentNrB   )r    r!   r"   r#   r   Úpropertyr4   r   r7   r9   r;   rA   r   r   r   r   r*     s    




r*   )r#   Úabcr   r   r   r)   Úfuture.utilsr   r   r%   r1   r*   r   r   r   r   Ú<module>   s   Xl&