o
    Bi                     @   s   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	 d dl
mZ d dlmZ d dlmZmZ d d	lmZmZ G d
d deZdS )    )StripeService)AuthenticationError)_api_encode)OAuth)	urlencode)RequestOptions)_ClientOptions)castOptional)NotRequired	TypedDictc                       s   e Zd ZU ee ed< d fdd	ZG dd deZdd Z	i i fd	e
jd
edefddZi fd	e
jd
ede
jfddZi fd	e
jd
ede
jfddZ  ZS )OAuthService_optionsNc                    s   t t| | || _d S N)superr   __init__r   )selfclientoptions	__class__ U/var/www/html/Trade-python/venv/lib/python3.10/site-packages/stripe/_oauth_service.pyr      s   
zOAuthService.__init__c                   @   s   e Zd ZU ee ed< dS )z%OAuthService.OAuthAuthorizeUrlOptionsexpressN)__name__
__module____qualname__r   bool__annotations__r   r   r   r   OAuthAuthorizeUrlOptions   s   
 r   c                 C   s2   d|v rd S | j o| j j}|r||d< d S td)N	client_ida  No client_id provided. (HINT: set your client_id when configuring your StripeClient: "stripe.StripeClient(..., client_id=<CLIENT_ID>)"). You can find your client_ids in your Stripe dashboard at https://dashboard.stripe.com/account/applications/settings, after registering your account as a platform. See https://stripe.com/docs/connect/standalone-accounts for details, or email support@stripe.com if you have any questions.)r   r    r   )r   paramsr    r   r   r   _set_client_id   s   zOAuthService._set_client_idr!   r   returnc                 C   sl   | drd}nd}| | d|vrd|d< ttt|}| jj d}|d us,J || d | }|S )Nr   z/express/oauth/authorizez/oauth/authorizeresponse_typecodeconnect?)getr"   r   listr   
_requestorbase_addresses)r   r!   r   pathqueryconnect_api_baseurlr   r   r   authorize_url/   s   

zOAuthService.authorize_urlc              	   C   s   t tj| jjdd||ddS )Npostz/oauth/tokenr&   r!   r   base_address)r	   r   
OAuthTokenr*   requestr   r!   r   r   r   r   tokenF   s   zOAuthService.tokenc              	   C   s(   |  | ttj| jjdd||ddS )Nr1   z/oauth/deauthorizer&   r2   )r"   r	   r   OAuthDeauthorizationr*   r5   r6   r   r   r   deauthorizeT   s   
zOAuthService.deauthorizer   )r   r   r   r
   r   r   r   r   r   r"   r   OAuthAuthorizeUrlParamsstrr0   OAuthTokenParamsr   r4   r7   OAuthDeauthorizeParamsr8   r9   __classcell__r   r   r   r   r      s<   
 

r   N)stripe._stripe_servicer   stripe._errorr   stripe._encoder   stripe._oauthr   urllib.parser   stripe._request_optionsr   stripe._client_optionsr   typingr	   r
   typing_extensionsr   r   r   r   r   r   r   <module>   s    