public BankAccount create ( BankAccount bankAccount , String customerId ) throws BaseException { logger . debug ( "Enter BankAccountService::create" ) ; if ( StringUtils . isBlank ( customerId ) ) { logger . error ( "IllegalArgumentException {}" , customerId ) ; throw new IllegalArgumentException ( "customerId cannot be empty or null" ) ; } // prepare API url String apiUrl = requestContext . getBaseUrl ( ) . replaceAll ( "payments" , "customers" ) + "{id}/bank-accounts" . replaceAll ( "\\{format\\}" , "json" ) . replaceAll ( "\\{" + "id" + "\\}" , customerId . toString ( ) ) ; logger . info ( "apiUrl - " + apiUrl ) ; // assign TypeReference for deserialization TypeReference < BankAccount > typeReference = new TypeReference < BankAccount > ( ) { } ; // prepare service request Request request = new Request . RequestBuilder ( MethodType . POST , apiUrl ) . requestObject ( bankAccount ) . typeReference ( typeReference ) . context ( requestContext ) . build ( ) ; // make API call Response response = sendRequest ( request ) ; // retrieve response BankAccount bankAccountResponse = ( BankAccount ) response . getResponseObject ( ) ; // set additional attributes prepareResponse ( request , response , bankAccountResponse ) ; return bankAccountResponse ; }
Method to create BankAccount for a given customer