o
    ȷe7                     @   s   d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlZdgZ	dZ
dd Zd	d
 Zdd Zdd Zdd ZG dd deZdS )    N)AWSQueryConnection)ResponseErrorFactory)ResponseFactoryFPSConnection)actionresponsec                 C   s"   t D ]}t||t| |d  q|S N)decorated_attrssetattrgetattr)functoattr r   J/var/www/ideatree/venv/lib/python3.10/site-packages/boto/fps/connection.pyadd_attrs_from$   s   r   c                         fdd}|S )Nc                    s0    fdd}d  jd|_t |dS )Nc                    s`   t |j D ]}||}t|dt|||d < t|d| j||d < q| g|R i |S )NValuez.ValueCurrencyCodez.CurrencyCode)filterhas_keypopr   strcurrencycode)selfargskwfieldamount)fieldsr   r   r   wrapper,   s   
z3complex_amounts.<locals>.decorator.<locals>.wrapperz{0}
Complex Amounts: {1}z, r   )format__doc__joinr   r   r    r   r   r   	decorator+   s
   z"complex_amounts.<locals>.decoratorr   )r   r(   r   r&   r   complex_amounts*   s   r)   c                     r   )Nc                    s>    fdd}d dd D }d j||_t |dS )Nc                     s\    fdd}dt t|kr'ddd D }dtdd	|}t|| i  S )
Nc                    s   t | t t j| kS r   )lenr   r   xr   r   r   <lambda>>   s    z>requires.<locals>.decorator.<locals>.wrapper.<locals>.<lambda>    OR c                 S      g | ]}d  |qS +r$   .0gr   r   r   
<listcomp>@       z@requires.<locals>.decorator.<locals>.wrapper.<locals>.<listcomp>z{0} requires {1} argument(s)r   Method)r*   r   r$   r"   r   KeyError)r   r   hasgroupmessage)r   groupsr-   r   r    =   s   z,requires.<locals>.decorator.<locals>.wrapperr0   c                 S   r1   r2   r4   r5   r   r   r   r8   E   r9   z/requires.<locals>.decorator.<locals>.<listcomp>z{0}
Required: {1}r!   )r$   r"   r#   r   )r   r    r=   r>   r'   r   r(   ;   s   zrequires.<locals>.decoratorr   )r>   r(   r   r?   r   requires9   s   r@   c                    s&    fdd}d  j|_t |dS )Nc                     s   | dt   | i |S )NCallerReference)
setdefaultuuiduuid4)r   r   r'   r   r   r    N   s   z'needs_caller_reference.<locals>.wrapperz2{0}
Uses CallerReference, defaults to uuid.uuid4()r!   )r"   r#   r   r%   r   r'   r   needs_caller_referenceL   s
   rE   c                     r   )Nc                    s|   d pttjjd t ttj	j
 d r%ttj	j
 d  fdd} |_|_
d j|_|S )N _Responsec                    s   |  g|R i |S r   r   r   r   r   r   r   r   r   r   r    ^   s   z.api_action.<locals>.decorator.<locals>.wrapperzFPS {0} API call
{1})r$   mapr   
capitalize__name__splitr   hasattrbotofpsr   r   r   r"   r#   r%   apirJ   r   r(   X   s   zapi_action.<locals>.decoratorr   )rS   r(   r   rR   r   
api_actionV   s   rT   c                       s  e Zd ZdZeZdZ fddZdd Ze	e
deg de d	d
 Zedge dd Zedge dd Zedge dd Ze dd Zedge dd Ze dd Ze dd Ze	eddge dd Ze	ed d!gd"d# Ze	e
d$eg d%e d&d' Ze	e
d$eg d%e d(d) Zedge d*d+ Ze
d$eg d,e d-d. Ze
d/eg d0e d1d2 Zed3ge d4d5 Zed6gd7ge d8d9 Zed:d;ge d<d= Ze d>d? Zed7ge d@dA Z ed7ge dBdC Z!e	e
dDeg dEe dFdG Z"edHge dIdJ Z#e	e
dKeg dLe dMdN Z$edOge dPdQ Z%edOge dRdS Z&e	e
d/edOge dTdU Z'ed7ge dVdW Z(  Z)S )Xr   z
2010-08-28USDc                    s6   | d| j| _|dd tt| j|i | d S )Nr   hostzfps.sandbox.amazonaws.com)r   r   rB   superr   __init__rI   	__class__r   r   rX   m   s   zFPSConnection.__init__c                 C   s   dgS )NrQ   r   )r   r   r   r   _required_auth_capabilityr   s   z'FPSConnection._required_auth_capabilitySettlementAmount)CreditInstrumentIdzSettlementAmount.ValueSenderTokenIdzSettlementAmount.CurrencyCodec                 K      |  |||S )z
        Allows a caller to initiate a transaction that atomically transfers
        money from a sender's payment instrument to the recipient, while
        decreasing corresponding debt balance.
        
get_objectr   r   r   r   r   r   r   settle_debtu      zFPSConnection.settle_debtTransactionIdc                 K   r_   )z:
        Gets the latest status of a transaction.
        r`   rb   r   r   r   get_transaction_status      z$FPSConnection.get_transaction_status	StartDatec                 K   r_   )z>
        Returns transactions for a given date range.
        r`   rb   r   r   r   get_account_activity   rg   z"FPSConnection.get_account_activityc                 K   r_   )z7
        Returns all details of a transaction.
        r`   rb   r   r   r   get_transaction   rg   zFPSConnection.get_transactionc                 C      |  |i |S )z~
        Returns the total outstanding balance for all the credit instruments
        for the given creditor account.
        r`   r   r   r   r   r   r   get_outstanding_debt_balance   rg   z*FPSConnection.get_outstanding_debt_balancePrepaidInstrumentIdc                 K   r_   )zP
        Returns the balance available on the given prepaid instrument.
        r`   rb   r   r   r   get_prepaid_balance   rg   z!FPSConnection.get_prepaid_balancec                 C   rk   )z
        Returns the total liability held by the given account corresponding to
        all the prepaid instruments owned by the account.
        r`   rl   r   r   r   get_total_prepaid_liability   rg   z)FPSConnection.get_total_prepaid_liabilityc                 C   rk   )zJ
        Returns the account balance for an account in real time.
        r`   rl   r   r   r   get_account_balance      z!FPSConnection.get_account_balancePaymentInstruction	TokenTypec                 K   r_   )z<
        Installs a payment instruction for caller.
        r`   rb   r   r   r   install_payment_instruction      z)FPSConnection.install_payment_instruction	returnURLpipelineNamec           
         s   d| j v rdpd}d|}d}d}|d |v sJ d|d	d
d |d| j dd fdd t fdd| D }dd }dd||||g}| j	|}	|d |	fg7 }|
  d||||S )zj
        Generate a signed URL for the Co-Branded service API given arguments as
        payload.
        sandboxzpayments-sandboxpaymentszauthorize.{0}.amazon.comz/cobranded-ui/actions/start)	SingleUseMultiUse	Recurring	RecipientSetupPrepaidSetupPostpaid	EditTokenrx   zInvalid pipelineName
HmacSHA2562)signatureMethodsignatureVersion	callerKeyc                 S   s   | d urt | p	dS )NrF   )r   r+   r   r   r   r.          z(FPSConnection.cbui_url.<locals>.<lambda>c                    s   t j | ddS )N~)safe)urllibquoter+   )safestrr   r   r.      s    c                    s   g | ]
\}}| |fqS r   r   r6   kv)	safequoter   r   r8          z*FPSConnection.cbui_url.<locals>.<listcomp>c                 S   s   d dd | D S )N&c                 S   s   g | ]
\}}|d  | qS )=r   r   r   r   r   r8      r   z<FPSConnection.cbui_url.<locals>.<lambda>.<locals>.<listcomp>r4   )pr   r   r   r.      r   
GET	signaturezhttps://{0}{1}?{2})rV   r"   updaterB   aws_access_key_idsorteditemsr$   _auth_handlersign_stringsort)
r   r   ry   endpointbasevalidpipelinespayloadencoded	canonicalr   r   )r   r   r   cbui_url   s&   
zFPSConnection.cbui_urlTransactionAmount)r^   TransactionAmount.ValueTransactionAmount.CurrencyCodec                 K   r_   )z
        Reserve API is part of the Reserve and Settle API conjunction that
        serve the purpose of a pay where the authorization and settlement have
        a timing difference.
        r`   rb   r   r   r   reserve   rd   zFPSConnection.reservec                 K   r_   )zY
        Allows calling applications to move money from a sender to a recipient.
        r`   rb   r   r   r   pay      	zFPSConnection.payc                 K   r_   )zP
        Cancels an ongoing transaction and puts it in cancelled state.
        r`   rb   r   r   r   cancel   rg   zFPSConnection.cancel)ReserveTransactionIdr   r   c                 K   r_   )z
        The Settle API is used in conjunction with the Reserve API and is used
        to settle previously reserved transaction.
        r`   rb   r   r   r   settle  r   zFPSConnection.settleRefundAmount)re   RefundAmount.ValuerA   zRefundAmount.CurrencyCodec                 K   r_   )z=
        Refunds a previously completed transaction.
        r`   rb   r   r   r   refund  s   zFPSConnection.refundRecipientTokenIdc                 K   r_   )z/
        Returns the recipient status.
        r`   rb   r   r   r   !get_recipient_verification_status  rg   z/FPSConnection.get_recipient_verification_statusrA   TokenIdc                 K   r_   )z
        Returns the details of a particular token installed by this calling
        application using the subway co-branded UI.
        r`   rb   r   r   r   get_token_by_caller  rv   z!FPSConnection.get_token_by_callerUrlEndPointHttpParametersc                 K   r_   )zM
        Verify the signature that FPS sent in IPN or callback urls.
        r`   rb   r   r   r   verify_signature(  rg   zFPSConnection.verify_signaturec                 K   r_   )zJ
        Returns a list of tokens installed on the given account.
        r`   rb   r   r   r   
get_tokens0  rr   zFPSConnection.get_tokensc                 K   r_   )z/
        Returns the usage of a token.
        r`   rb   r   r   r   get_token_usage7  rg   zFPSConnection.get_token_usagec                 K   r_   )zd
        Cancels any token installed by the calling application on its own
        account.
        r`   rb   r   r   r   cancel_token?  rv   zFPSConnection.cancel_tokenFundingAmount)rn   zFundingAmount.Valuer^   zFundingAmount.CurrencyCodec                 K   r_   )zL
        Funds the prepaid balance on the given prepaid instrument.
        r`   rb   r   r   r   fund_prepaidH  r   zFPSConnection.fund_prepaidr]   c                 K   r_   )zS
        Returns the balance corresponding to the given credit instrument.
        r`   rb   r   r   r   get_debt_balanceS  rg   zFPSConnection.get_debt_balanceAdjustmentAmount)r]   zAdjustmentAmount.ValuezAdjustmentAmount.CurrencyCodec                 K   r_   )zu
        Allows a creditor to write off the debt balance accumulated partially
        or fully at any time.
        r`   rb   r   r   r   write_off_debt[  s   
zFPSConnection.write_off_debtSubscriptionIdc                 K   r_   )zF
        Returns the transactions for a given subscriptionID.
        r`   rb   r   r   r   !get_transactions_for_subscriptiong  rg   z/FPSConnection.get_transactions_for_subscriptionc                 K   r_   )zQ
        Returns the details of Subscription for a given subscriptionID.
        r`   rb   r   r   r   get_subscription_detailso  rg   z&FPSConnection.get_subscription_detailsc                 K   s*   d}d|vsd|v sJ ||  |||S )z)
        Cancels a subscription.
        z@If you specify a RefundAmount, you must specify CallerReference.r   rA   r`   )r   r   r   r   r=   r   r   r   cancel_subscription_and_refundw  s   z,FPSConnection.cancel_subscription_and_refundc                 K   r_   )z:
        Gets the payment instruction of a token.
        r`   rb   r   r   r   get_payment_instruction  rg   z%FPSConnection.get_payment_instruction)*rM   
__module____qualname__
APIVersionr   ResponseErrorr   rX   r[   rE   r)   r@   rT   rc   rf   ri   rj   rm   ro   rp   rq   ru   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __classcell__r   r   rY   r   r   g   s    














)r   rC   boto.connectionr   boto.fps.exceptionr   boto.fps.responser   rP   __all__r	   r   r)   r@   rE   rT   r   r   r   r   r   <module>   s   
