public Charge create ( Charge charge ) throws BaseException { logger . debug ( "Enter ChargeService::create" ) ; // prepare API url String apiUrl = requestContext . getBaseUrl ( ) + "charges" . replaceAll ( "\\{format\\}" , "json" ) ; logger . info ( "apiUrl - " + apiUrl ) ; // assign TypeReference for deserialization TypeReference < Charge > typeReference = new TypeReference < Charge > ( ) { } ; // prepare service request Request request = new Request . RequestBuilder ( MethodType . POST , apiUrl ) . requestObject ( charge ) . typeReference ( typeReference ) . context ( requestContext ) . build ( ) ; // make API call Response response = sendRequest ( request ) ; // retrieve response Charge chargeResponse = ( Charge ) response . getResponseObject ( ) ; // set additional attributes prepareResponse ( request , response , chargeResponse ) ; return chargeResponse ; }
Method to create Charge