<s> import urllib <EOL> import uuid <EOL> from boto . connection import AWSQueryConnection <EOL> from boto . fps . exception import ResponseErrorFactory <EOL> from boto . fps . response import ResponseFactory <EOL> import boto . fps . response <EOL> __all__ = [ '<STR_LIT>' ] <EOL> decorated_attrs = ( '<STR_LIT:action>' , '<STR_LIT>' ) <EOL> def add_attrs_from ( func , to ) : <EOL> for attr in decorated_attrs : <EOL> setattr ( to , attr , getattr ( func , attr , None ) ) <EOL> return to <EOL> def complex_amounts ( * fields ) : <EOL> def decorator ( func ) : <EOL> def wrapper ( self , * args , ** kw ) : <EOL> for field in filter ( kw . has_key , fields ) : <EOL> amount = kw . pop ( field ) <EOL> kw [ field + '<STR_LIT>' ] = getattr ( amount , '<STR_LIT>' , str ( amount ) ) <EOL> kw [ field + '<STR_LIT>' ] = getattr ( amount , '<STR_LIT>' , <EOL> self . currencycode ) <EOL> return func ( self , * args , ** kw ) <EOL> wrapper . __doc__ = "<STR_LIT>" . format ( func . __doc__ , <EOL> '<STR_LIT:U+002CU+0020>' . join ( fields ) ) <EOL> return add_attrs_from ( func , to = wrapper ) <EOL> return decorator <EOL> def requires ( * groups ) : <EOL> def decorator ( func ) : <EOL> def wrapper ( * args , ** kw ) : <EOL> hasgroup = lambda x : len ( x ) == len ( filter ( kw . has_key , x ) ) <EOL> if <NUM_LIT:1> != len ( filter ( hasgroup , groups ) ) : <EOL> message = '<STR_LIT>' . join ( [ '<STR_LIT:+>' . join ( g ) for g in groups ] ) <EOL> message = "<STR_LIT>" "<STR_LIT>" . format ( getattr ( func , '<STR_LIT:action>' , '<STR_LIT>' ) , message ) <EOL> raise KeyError ( message ) <EOL> return func ( * args , ** kw ) <EOL> message = '<STR_LIT>' . join ( [ '<STR_LIT:+>' . join ( g ) for g in groups ] ) <EOL> wrapper . __doc__ = "<STR_LIT>" . format ( func . __doc__ , <EOL> message ) <EOL> return add_attrs_from ( func , to = wrapper ) <EOL> return decorator <EOL> def needs_caller_reference ( func ) : <EOL> def wrapper ( * args , ** kw ) : <EOL> kw . setdefault ( '<STR_LIT>' , uuid . uuid4 ( ) ) <EOL> return func ( * args , ** kw ) <EOL> wrapper . __doc__ = "<STR_LIT>" "<STR_LIT>" . format ( func . __doc__ ) <EOL> return add_attrs_from ( func , to = wrapper ) <EOL> def api_action ( * api ) : <EOL> def decorator ( func ) : <EOL> action = '<STR_LIT>' . join ( api or map ( str . capitalize , func . __name__ . split ( '<STR_LIT:_>' ) ) ) <EOL> response = ResponseFactory ( action ) <EOL> if hasattr ( boto . fps . response , action + '<STR_LIT>' ) : <EOL> response = getattr ( boto . fps . response , action + '<STR_LIT>' ) <EOL> def wrapper ( self , * args , ** kw ) : <EOL> return func ( self , action , response , * args , ** kw ) <EOL> wrapper . action , wrapper . response = action , response <EOL> wrapper . __doc__ = "<STR_LIT>" . format ( action , <EOL> func . __doc__ ) <EOL> return wrapper <EOL> return decorator <EOL> class FPSConnection ( AWSQueryConnection ) : <EOL> APIVersion = '<STR_LIT>' <EOL> ResponseError = ResponseErrorFactory <EOL> currencycode = '<STR_LIT>' <EOL> def __init__ ( self , * args , ** kw ) : <EOL> self . currencycode = kw . pop ( '<STR_LIT>' , self . currencycode ) <EOL> kw . setdefault ( '<STR_LIT:host>' , '<STR_LIT>' ) <EOL> super ( FPSConnection , self ) . __init__ ( * args , ** kw ) <EOL> def _required_auth_capability ( self ) : <EOL> return [ '<STR_LIT>' ] <EOL> @ needs_caller_reference <EOL> @ complex_amounts ( '<STR_LIT>' ) <EOL> @ requires ( [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def settle_debt ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ requires ( [ '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def get_transaction_status ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ requires ( [ '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def get_account_activity ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ requires ( [ '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def get_transaction ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ api_action ( ) <EOL> def get_outstanding_debt_balance ( self , action , response ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , { } , response ) <EOL> @ requires ( [ '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def get_prepaid_balance ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ api_action ( ) <EOL> def get_total_prepaid_liability ( self , action , response ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , { } , response ) <EOL> @ api_action ( ) <EOL> def get_account_balance ( self , action , response ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , { } , response ) <EOL> @ needs_caller_reference <EOL> @ requires ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def install_payment_instruction ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ needs_caller_reference <EOL> @ requires ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> def cbui_url ( self , ** kw ) : <EOL> """<STR_LIT>""" <EOL> sandbox = '<STR_LIT>' in self . host and '<STR_LIT>' or '<STR_LIT>' <EOL> endpoint = '<STR_LIT>' . format ( sandbox ) <EOL> base = '<STR_LIT>' <EOL> validpipelines = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> assert kw [ '<STR_LIT>' ] in validpipelines , "<STR_LIT>" <EOL> kw . update ( { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:2>' , <EOL> } ) <EOL> kw . setdefault ( '<STR_LIT>' , self . aws_access_key_id ) <EOL> safestr = lambda x : x is not None and str ( x ) or '<STR_LIT>' <EOL> safequote = lambda x : urllib . quote ( safestr ( x ) , safe = '<STR_LIT>' ) <EOL> payload = sorted ( [ ( k , safequote ( v ) ) for k , v in kw . items ( ) ] ) <EOL> encoded = lambda p : '<STR_LIT:&>' . join ( [ k + '<STR_LIT:=>' + v for k , v in p ] ) <EOL> canonical = '<STR_LIT:\n>' . join ( [ '<STR_LIT:GET>' , endpoint , base , encoded ( payload ) ] ) <EOL> signature = self . _auth_handler . sign_string ( canonical ) <EOL> payload += [ ( '<STR_LIT>' , safequote ( signature ) ) ] <EOL> payload . sort ( ) <EOL> return '<STR_LIT>' . format ( endpoint , base , encoded ( payload ) ) <EOL> @ needs_caller_reference <EOL> @ complex_amounts ( '<STR_LIT>' ) <EOL> @ requires ( [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def reserve ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ needs_caller_reference <EOL> @ complex_amounts ( '<STR_LIT>' ) <EOL> @ requires ( [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def pay ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ requires ( [ '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def cancel ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ complex_amounts ( '<STR_LIT>' ) <EOL> @ requires ( [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def settle ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ complex_amounts ( '<STR_LIT>' ) <EOL> @ requires ( [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def refund ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ requires ( [ '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def get_recipient_verification_status ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ requires ( [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def get_token_by_caller ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ requires ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def verify_signature ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ api_action ( ) <EOL> def get_tokens ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ requires ( [ '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def get_token_usage ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ requires ( [ '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def cancel_token ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ needs_caller_reference <EOL> @ complex_amounts ( '<STR_LIT>' ) <EOL> @ requires ( [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def fund_prepaid ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ requires ( [ '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def get_debt_balance ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ needs_caller_reference <EOL> @ complex_amounts ( '<STR_LIT>' ) <EOL> @ requires ( [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def write_off_debt ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ requires ( [ '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def get_transactions_for_subscription ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ requires ( [ '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def get_subscription_details ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) <EOL> @ needs_caller_reference <EOL> @ complex_amounts ( '<STR_LIT>' ) <EOL> @ requires ( [ '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def cancel_subscription_and_refund ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> message = "<STR_LIT>" "<STR_LIT>" <EOL> assert not '<STR_LIT>' in kw or '<STR_LIT>' in kw , message <EOL> return self . get_object ( action , kw , response ) <EOL> @ requires ( [ '<STR_LIT>' ] ) <EOL> @ api_action ( ) <EOL> def get_payment_instruction ( self , action , response , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( action , kw , response ) </s>
