o
    BiRQ                     @   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mZmZmZmZ d d
lmZmZmZmZ G dd ded ed ed ed ZdS )    )CreateableAPIResource)DeletableAPIResource)
ListObject)ListableAPIResource)RequestOptions)StripeObject)UpdateableAPIResource)class_method_variantsanitize_id)ClassVarDictListOptionalcastoverload)LiteralNotRequired	TypedDictUnpackc                   @   s  e Zd ZU dZdZeed  ed< G dd deZ	G dd deZ
G dd	 d	eZG d
d deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZee ed< 	 ee	 ed< eed< 	 ee ed< 	 eeee
f  ed< 	 ed ed < 	 ee ed!< 	 eed"< 	 eed#< 	 ee ed$< 	 eeeef  ed%< 	 ee ed&< 	 ed ed'< 	 ee ed(< 	 ee ed)< 	 eed*< 	 eed+< 	 eed,  ed-< 	 ed.ed/ d0d fd1d2Zed.ed/ d0d fd3d4Zed5ed.ed6 d0d fd7d8Z e!e"d5ed.ed6 d0d fd9d:Z#e!d.ed6 d0d fd;d:Z#e$d<d.ed6 d0d fd=d:Z#ed5ed.ed6 d0d fd>d?Z%e!e"d5ed.ed6 d0d fd@dAZ&e!d.ed6 d0d fdBdAZ&e$dCd.ed6 d0d fdDdAZ&ed.edE d0e'd  fdFdGZ(ed.edE d0e'd  fdHdIZ)ed"ed.edJ d0d fdKdLZ*ed"ed.edJ d0d fdMdNZ+ed"ed.edO d0d fdPdQZ,ed"ed.edO d0d fdRdSZ-e	e
dTZ.dUS )VCoupona+  
    A coupon contains information about a percent-off or amount-off discount you
    might want to apply to a customer. Coupons may be applied to [subscriptions](https://stripe.com/docs/api#subscriptions), [invoices](https://stripe.com/docs/api#invoices),
    [checkout sessions](https://stripe.com/docs/api/checkout/sessions), [quotes](https://stripe.com/docs/api#quotes), and more. Coupons do not work with conventional one-off [charges](https://stripe.com/docs/api#create_charge) or [payment intents](https://stripe.com/docs/api/payment_intents).
    couponOBJECT_NAMEc                   @   s   e Zd ZU ee ed< dS )zCoupon.AppliesToproductsN)__name__
__module____qualname__r   str__annotations__ r   r   N/var/www/html/Trade-python/venv/lib/python3.10/site-packages/stripe/_coupon.py	AppliesTo   s   
 r    c                   @      e Zd ZU eed< dS )zCoupon.CurrencyOptions
amount_offNr   r   r   intr   r   r   r   r   CurrencyOptions#      
 r%   c                   @   s   e Zd ZU ee ed< 	 ed ed< 	 ee ed< 	 eeedf  ed< 	 eed  ed< 	 ee ed	< 	 ee	e  ed
< 	 ee ed< 	 ee ed< 	 ed ed< 	 ee ed< 	 ee
 ed< 	 ee ed< dS )Coupon.CreateParamsr"   Coupon.CreateParamsAppliesTo
applies_tocurrency"Coupon.CreateParamsCurrencyOptionscurrency_optionsforeveronce	repeatingdurationduration_in_monthsexpandidmax_redemptionsLiteral['']|Dict[str, str]metadatanamepercent_off	redeem_byN)r   r   r   r   r$   r   r   r   r   r   floatr   r   r   r   CreateParams)   s:   
 
r<   c                   @      e Zd ZU eee  ed< dS )r(   r   Nr   r   r   r   r   r   r   r   r   r   r   CreateParamsAppliesToa      
 r?   c                   @   r!   )r+   r"   Nr#   r   r   r   r   CreateParamsCurrencyOptionsg   r&   rA   c                   @   s   e Zd ZdS )Coupon.DeleteParamsN)r   r   r   r   r   r   r   DeleteParamsm   s    rC   c                   @   sV   e Zd ZU ed ed< 	 ee ed< 	 eee  ed< 	 ee ed< 	 ee ed< dS )Coupon.ListParamszCoupon.ListParamsCreated|intcreatedending_beforer3   limitstarting_afterN)r   r   r   r   r   r   r   r$   r   r   r   r   
ListParamsp   s   
 rI   c                   @   sD   e Zd ZU ee ed< 	 ee ed< 	 ee ed< 	 ee ed< dS )zCoupon.ListParamsCreatedgtgteltlteN)r   r   r   r   r$   r   r   r   r   r   ListParamsCreated   s   
 rN   c                   @   sP   e Zd ZU eeedf  ed< 	 eee  ed< 	 ed ed< 	 ee ed< dS )Coupon.ModifyParams"Coupon.ModifyParamsCurrencyOptionsr,   r3   r6   r7   r8   N)r   r   r   r   r   r   r   r   r   r   r   r   ModifyParams   s   
 
rQ   c                   @   r!   )rP   r"   Nr#   r   r   r   r   ModifyParamsCurrencyOptions   r&   rR   c                   @   r=   )Coupon.RetrieveParamsr3   Nr>   r   r   r   r   RetrieveParams   r@   rT   r"   r)   rE   r*   r,   r-   r1   r2   r4   livemoder5   r7   r8   objectr9   r:   times_redeemedvalidTdeletedparamsr'   returnc                 K   s   t d| jd|  |dS )  
        You can create coupons easily via the [coupon management](https://dashboard.stripe.com/coupons) page of the Stripe dashboard. Coupon creation is also accessible via the API if you need to create coupons on the fly.

        A coupon has either a percent_off or an amount_off and currency. If you set an amount_off, that amount will be subtracted from any invoice's subtotal. For example, an invoice with a subtotal of 100 will have a final total of 0 if a coupon with an amount_off of 200 is applied to it and an invoice with a subtotal of 300 will have a final total of 100 if a coupon with an amount_off of 200 is applied to it.
        r   postrZ   )r   _static_request	class_urlclsrZ   r   r   r   create   s   zCoupon.createc                    s"   t d| jd|  |dI dH S )r\   r   r]   r^   N)r   _static_request_asyncr`   ra   r   r   r   create_async  s   	
zCoupon.create_asyncsidrB   c                 K   *   d|   t|f }td| jd||dS )D  
        You can delete coupons via the [coupon management](https://dashboard.stripe.com/coupons) page of the Stripe dashboard. However, deleting a coupon does not affect any customers who have already applied the coupon; it means that new customers can't redeem the coupon. You can also delete coupons via the API.
        %s/%sr   deleter^   r`   r
   r   r_   rb   rf   rZ   urlr   r   r   _cls_delete      zCoupon._cls_deletec                 K      dS rh   Nr   rf   rZ   r   r   r   rj   1  s   zCoupon.deletec                 K   rp   rq   r   selfrZ   r   r   r   rj   9  s   rn   c                 K   s   | j d|  |dS )rh   rj   r^   )_request_and_refreshinstance_urlrs   r   r   r   rj   @  s
   c                    2   d|   t|f }td| jd||dI dH S )rh   ri   r   rj   r^   Nr`   r
   r   rd   rl   r   r   r   _cls_delete_asyncM     
zCoupon._cls_delete_asyncc                       dS rq   r   rr   r   r   r   delete_async^  s   zCoupon.delete_asyncc                    r{   rq   r   rs   r   r   r   r|   h  s   ry   c                    s   | j d|  |dI dH S )rh   rj   r^   N)_request_and_refresh_asyncrv   rs   r   r   r   r|   q  s   rD   c                 K   s4   | j d|  |d}t|tstdt|j |S )1
        Returns a list of your coupons.
        getr^   %Expected list object from API, got %s)r_   r`   
isinstancer   	TypeErrortyper   rb   rZ   resultr   r   r   list~  s   
zCoupon.listc                    s<   | j d|  |dI dH }t|tstdt|j |S )r~   r   r^   Nr   )rd   r`   r   r   r   r   r   r   r   r   r   
list_async  s   
zCoupon.list_asyncrO   c                 K   rg   )
        Updates the metadata of a coupon. Other coupon details (currency, duration, amount_off) are, by design, not editable.
        ri   r   r]   r^   rk   rb   r4   rZ   rm   r   r   r   modify  ro   zCoupon.modifyc                    rw   )r   ri   r   r]   r^   Nrx   r   r   r   r   modify_async  rz   zCoupon.modify_asyncrS   c                 K   s   | |fi |}|   |S )9
        Retrieves the coupon with the given ID.
        )refreshrb   r4   rZ   instancer   r   r   retrieve  s   zCoupon.retrievec                    s$   | |fi |}|  I dH  |S )r   N)refresh_asyncr   r   r   r   retrieve_async  s   zCoupon.retrieve_async)r)   r,   N)/r   r   r   __doc__r   r   r   r   r   r    r%   r   r<   r   r?   rA   rC   rI   rN   rQ   rR   rT   r   r$   r   r   boolr;   classmethodr   rc   re   rn   r   staticmethodrj   r	   ry   r|   r   r   r   r   r   r   r   _inner_class_typesr   r   r   r   r      s0  
 8

r   N)stripe._createable_api_resourcer   stripe._deletable_api_resourcer   stripe._list_objectr   stripe._listable_api_resourcer   stripe._request_optionsr   stripe._stripe_objectr   stripe._updateable_api_resourcer   stripe._utilr	   r
   typingr   r   r   r   r   r   typing_extensionsr   r   r   r   r   r   r   r   r   <module>   s     
