o
    ib                     @   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	m
Z
 d dlmZmZmZ er>d dlmZ d dlmZ d d	lmZ G d
d deZdS )    )StripeService)AuthenticationError)_api_encode)	urlencode)castOptional)NotRequired	TypedDictTYPE_CHECKING)_ClientOptions)RequestOptions)OAuthc                       s   e Zd ZU ed ed< d fdd	ZG dd deZdd	 Z		dd
ed dee de	fddZ
	dd
dded ddfddZ	dd
dded ddfddZ  ZS )OAuthServicer   _optionsNc                    s   t t| | || _d S N)superr   __init__r   )selfclientoptions	__class__ u/var/www/snowflake_co_dev_github/snow_flake_back_end_deploy/env/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"   zOAuth.OAuthAuthorizeUrlParamsr   returnc                 C   s   |d u ri }|d u ri }| drd}nd}| | d|vr#d|d< ttt|d}| jj d}|d us9J || d | }|S )	Nr   z/express/oauth/authorizez/oauth/authorizeresponse_typecodeV1connect?)getr#   r   listr   
_requestorbase_addresses)r   r"   r   pathqueryconnect_api_baseurlr   r   r   authorize_url1   s   

zOAuthService.authorize_urlzOAuth.OAuthTokenParamsr   OAuth.OAuthTokenc              	   C   s(   |d u ri }t d| jjdd||ddS )Nr3   postz/oauth/tokenr(   r"   r   base_address)r   r,   requestr   r"   r   r   r   r   tokenM   s   zOAuthService.tokenzOAuth.OAuthDeauthorizeParamsOAuth.OAuthDeauthorizationc              	   C   s2   |d u ri }|  | td| jjdd||ddS )Nr:   r4   z/oauth/deauthorizer(   r5   )r#   r   r,   r7   r8   r   r   r   deauthorize_   s   
zOAuthService.deauthorizer   )NN)r   r   r   r   r   r   r	   r    r#   strr2   r9   r;   __classcell__r   r   r   r   r      s<   
 

r   N)stripe._stripe_servicer   stripe._errorr   stripe._encoder   urllib.parser   typingr   r   typing_extensionsr   r	   r
   stripe._client_optionsr   stripe._request_optionsr   stripe._oauthr   r   r   r   r   r   <module>   s    