@ SuppressWarnings ( "unchecked" ) public QueryResponse getAllBankAccounts ( String customerId , int count ) throws BaseException { logger . debug ( "Enter BankAccountService::getAllBankAccounts" ) ; 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 ( ) ) ; if ( count > 0 ) { apiUrl = apiUrl + "?count=" + count ; } logger . info ( "apiUrl - " + apiUrl ) ; // assign TypeReference for deserialization TypeReference < List < BankAccount > > typeReference = new TypeReference < List < BankAccount > > ( ) { } ; // prepare service request Request request = new Request . RequestBuilder ( MethodType . GET , apiUrl ) . typeReference ( typeReference ) . context ( requestContext ) . build ( ) ; // make API call Response response = sendRequest ( request ) ; // retrieve response List < BankAccount > bankAccounts = ( List < BankAccount > ) response . getResponseObject ( ) ; QueryResponse queryResponse = new QueryResponse . Builder ( ) . bankAccounts ( bankAccounts ) . build ( ) ; // set additional attributes prepareResponse ( request , response , queryResponse ) ; return queryResponse ; }
Method to Get All BankAccounts for a given customer specifying the count of records to be returned