o
    h                     @   sR   d dl mZmZ d dlmZ d dlmZ G dd deZG dd deZegZ	dS )	    )
AuthActionProviderAccount)OAuthProvider)TwitterOAuthAdapterc                       s4   e Zd Zdd Zdd Zdd Z fddZ  ZS )	TwitterAccountc                 C   s   | j jdS )z7The screen name is the username of the Twitter account.screen_name)account
extra_dataget)self r   g/var/www/html/pos/venv/lib/python3.10/site-packages/allauth/socialaccount/providers/twitter/provider.pyget_screen_name   s   zTwitterAccount.get_screen_namec                 C   s   d }|   }|rd| }|S )Nzhttp://twitter.com/)r   )r   retr   r   r   r   get_profile_url   s
   zTwitterAccount.get_profile_urlc                 C   s&   d }| j jd}|r|dd}|S )Nprofile_image_url_normal )r   r	   r
   replace)r   r   r   r   r   r   get_avatar_url   s
   zTwitterAccount.get_avatar_urlc                    s   |   }|ptt|  S )N)r   superr   to_str)r   r   	__class__r   r   r      s   zTwitterAccount.to_str)__name__
__module____qualname__r   r   r   r   __classcell__r   r   r   r   r      s
    	r   c                   @   s4   e Zd ZdZdZeZeZdd Z	dd Z
dd Zd	S )
TwitterProvidertwitterTwitterc                 C   s   |t jkr	d}|S d}|S )Nz'https://api.twitter.com/oauth/authorizez*https://api.twitter.com/oauth/authenticate)r   REAUTHENTICATE)r   requestactionurlr   r   r   get_auth_url&   s
   
zTwitterProvider.get_auth_urlc                 C   s   t |d S )Nid)strr   datar   r   r   extract_uid-   s   zTwitterProvider.extract_uidc                 C   s    t |d|d|ddS )Nr   nameemail)usernamer+   r,   )dictr
   r(   r   r   r   extract_common_fields0   s
   z%TwitterProvider.extract_common_fieldsN)r   r   r   r&   r+   r   account_classr   oauth_adapter_classr%   r*   r/   r   r   r   r   r       s    r   N)
$allauth.socialaccount.providers.baser   r   .allauth.socialaccount.providers.oauth.providerr   -allauth.socialaccount.providers.twitter.viewsr   r   r   provider_classesr   r   r   r   <module>   s    
