a
    g                     @   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e
jeed	d
dZi fe
jee
jd	ddZi fe
jee
jd	ddZ  ZS )OAuthService_optionsNc                    s   t t| | || _d S )N)superr   __init__r   )selfclientoptions	__class__ c/var/www/staging/api/virtual_environments/venv/lib/python3.9/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   s6   d|v rd S | j o| j j}|r*||d< d S tdd S )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_id)r    r   returnc                 C   sn   | drd}nd}| | d|vr.d|d< ttt|d}| jj d}|d usZJ || d | }|S )	Nr   z/express/oauth/authorizez/oauth/authorizeZresponse_typecodeZV1connect?)getr!   r   listr   
_requestorZbase_addresses)r   r    r   pathqueryZ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   Z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 )Nr-   z/oauth/deauthorizer$   r.   )r!   r	   r   OAuthDeauthorizationr(   r0   r1   r   r   r   deauthorizeT   s    
zOAuthService.deauthorize)N)r   r   r   r
   r   r   r   r   r   r!   r   ZOAuthAuthorizeUrlParamsstrr,   ZOAuthTokenParamsr   r/   r2   ZOAuthDeauthorizeParamsr3   r4   __classcell__r   r   r   r   r      s,   
r   N)Zstripe._stripe_servicer   Zstripe._errorr   Zstripe._encoder   Zstripe._oauthr   urllib.parser   Zstripe._request_optionsr   Zstripe._client_optionsr   typingr	   r
   Ztyping_extensionsr   r   r   r   r   r   r   <module>   s   