<s> from braintree . error_result import ErrorResult <EOL> from braintree . merchant_account import MerchantAccount <EOL> from braintree . resource import Resource <EOL> from braintree . successful_result import SuccessfulResult <EOL> from braintree . exceptions . not_found_error import NotFoundError <EOL> class MerchantAccountGateway ( object ) : <EOL> def __init__ ( self , gateway ) : <EOL> self . gateway = gateway <EOL> self . config = gateway . config <EOL> def create ( self , params = { } ) : <EOL> Resource . verify_keys ( params , MerchantAccountGateway . _detect_signature ( params ) ) <EOL> return self . _post ( "<STR_LIT>" , { "<STR_LIT>" : params } ) <EOL> def update ( self , merchant_account_id , params = { } ) : <EOL> Resource . verify_keys ( params , MerchantAccountGateway . _update_signature ( ) ) <EOL> return self . _put ( "<STR_LIT>" % merchant_account_id , { "<STR_LIT>" : params } ) <EOL> def find ( self , merchant_account_id ) : <EOL> try : <EOL> if merchant_account_id is None or merchant_account_id . strip ( ) == "<STR_LIT>" : <EOL> raise NotFoundError ( ) <EOL> response = self . config . http ( ) . get ( self . config . base_merchant_path ( ) + "<STR_LIT>" + merchant_account_id ) <EOL> return MerchantAccount ( self . gateway , response [ "<STR_LIT>" ] ) <EOL> except NotFoundError : <EOL> raise NotFoundError ( "<STR_LIT>" + repr ( merchant_account_id ) + "<STR_LIT>" ) <EOL> def _post ( self , url , params = { } ) : <EOL> response = self . config . http ( ) . post ( self . config . base_merchant_path ( ) + url , params ) <EOL> if "<STR_LIT>" in response : <EOL> return SuccessfulResult ( { "<STR_LIT>" : MerchantAccount ( self . gateway , response [ "<STR_LIT>" ] ) } ) <EOL> elif "<STR_LIT>" in response : <EOL> return ErrorResult ( self . gateway , response [ "<STR_LIT>" ] ) <EOL> def _put ( self , url , params = { } ) : <EOL> response = self . config . http ( ) . put ( self . config . base_merchant_path ( ) + url , params ) <EOL> if "<STR_LIT>" in response : <EOL> return SuccessfulResult ( { "<STR_LIT>" : MerchantAccount ( self . gateway , response [ "<STR_LIT>" ] ) } ) <EOL> elif "<STR_LIT>" in response : <EOL> return ErrorResult ( self . gateway , response [ "<STR_LIT>" ] ) <EOL> @ staticmethod <EOL> def _detect_signature ( attributes ) : <EOL> if '<STR_LIT>' in attributes : <EOL> return MerchantAccountGateway . _create_deprecated_signature ( ) <EOL> else : <EOL> return MerchantAccountGateway . _create_signature ( ) <EOL> @ staticmethod <EOL> def _create_deprecated_signature ( ) : <EOL> return [ <EOL> { '<STR_LIT>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:email>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> { '<STR_LIT:address>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] } <EOL> ] <EOL> } , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:id>' <EOL> ] <EOL> @ staticmethod <EOL> def _create_signature ( ) : <EOL> return [ <EOL> { '<STR_LIT>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:email>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> { '<STR_LIT:address>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] } <EOL> ] <EOL> } , <EOL> { '<STR_LIT>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> { '<STR_LIT:address>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] } <EOL> ] <EOL> } , <EOL> { '<STR_LIT>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:email>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> } , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:id>' <EOL> ] <EOL> @ staticmethod <EOL> def _update_signature ( ) : <EOL> return [ <EOL> { '<STR_LIT>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:email>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> { '<STR_LIT:address>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] } <EOL> ] <EOL> } , <EOL> { '<STR_LIT>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> { '<STR_LIT:address>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] } <EOL> ] <EOL> } , <EOL> { '<STR_LIT>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:email>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> } , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:id>' <EOL> ] </s>
