@@ -144,8 +144,6 @@ public class ApiClient {
144144
145145 public String responseCode ;
146146 public String status ;
147- public InputStream responseBody ;
148- public String respBody ;
149147 public MerchantConfig merchantConfig ;
150148 public RequestTransactionMetrics apiRequestMetrics = new RequestTransactionMetrics ();
151149
@@ -1035,7 +1033,9 @@ public <T> T deserialize(Response response, Type returnType) throws ApiException
10351033 // Handle file downloading.
10361034 return (T ) downloadFileFromResponse (response );
10371035 }
1038-
1036+
1037+ String respBody = null ;
1038+
10391039 try {
10401040 if (response .body () != null )
10411041 respBody = response .body ().string ();
@@ -1191,8 +1191,9 @@ public <T> ApiResponse<T> execute(Call call, Type returnType) throws ApiExceptio
11911191 try {
11921192 this .apiRequestMetrics .setComputeTime ((System .nanoTime () - this .getComputationStartTime ()) / 1000000 );
11931193 Response response = call .execute ();
1194- responseCode = String .valueOf (response .code ());
1195- status = response .message ();
1194+ String responseCode = String .valueOf (response .code ());
1195+ this .status = response .message ();
1196+ this .responseCode = responseCode ;
11961197
11971198 logger .debug ("Network Response :\n " + json .serialize (response .headers ()));
11981199
@@ -1317,16 +1318,19 @@ public <T> T handleResponse(Response response, Type returnType) throws ApiExcept
13171318 public Call buildCall (String path , String method , List <Pair > queryParams , Object body ,
13181319 Map <String , String > headerParams , Map <String , Object > formParams , String [] authNames ,
13191320 ProgressRequestBody .ProgressRequestListener progressRequestListener ) throws ApiException {
1320-
1321- if (merchantConfig .getDefaultHeaders () != null && !merchantConfig .getDefaultHeaders ().isEmpty ()) { //check fr this test case
1321+
1322+ //create reqHeader parameter here
1323+ Map <String , String > requestHeaderMap = new HashMap <String , String >();
1324+
1325+ if (merchantConfig .getDefaultHeaders () != null && !merchantConfig .getDefaultHeaders ().isEmpty ()) {
13221326 for (Entry <String , String > header : merchantConfig .getDefaultHeaders ().entrySet ()) {
13231327 if (!header .getKey ().equalsIgnoreCase ("Authorization" ) && !header .getKey ().equalsIgnoreCase ("Signature" )){
1324- addDefaultHeader (header .getKey (), header .getValue ());
1328+ requestHeaderMap . put (header .getKey (), header .getValue ());
13251329 }
13261330 }
13271331 }
13281332
1329- callAuthenticationHeader (method , path , body , queryParams );
1333+ callAuthenticationHeader (method , path , body , queryParams , requestHeaderMap );
13301334
13311335 if (merchantConfig .isEnableClientCert ()) {
13321336 addClientCertToKeyStore ();
@@ -1339,10 +1343,11 @@ public Call buildCall(String path, String method, List<Pair> queryParams, Object
13391343 headerParams .put ("Accept" , defaultAcceptHeader );
13401344 }
13411345
1342- headerParams .putAll (defaultHeaderMap );
1346+ headerParams .putAll (requestHeaderMap );
13431347
13441348
13451349 logger .info ("Request Header Parameters:\n {}" , new PrettyPrintingMap <String , String >(headerParams ));
1350+ //till here completed
13461351 Request request = buildRequest (path , method , queryParams , body , headerParams , formParams , authNames ,
13471352 progressRequestListener );
13481353 return httpClient .newCall (request );
@@ -1353,7 +1358,7 @@ public Call buildCall(String path, String method, List<Pair> queryParams, Object
13531358 *
13541359 */
13551360
1356- public void callAuthenticationHeader (String method , String path , Object body , List <Pair > queryParams ) {
1361+ public void callAuthenticationHeader (String method , String path , Object body , List <Pair > queryParams , Map < String , String > requestHeaderMap ) {
13571362
13581363 try {
13591364 String requestTarget = null ;
@@ -1395,40 +1400,37 @@ public void callAuthenticationHeader(String method, String path, Object body, Li
13951400 }
13961401
13971402 logger .debug ("HTTP Request Body:\n " + requestBody );
1398- authorization .setJWTRequestBody (requestBody );
13991403 boolean isMerchantDetails = merchantConfig .validateMerchantDetails (method );
14001404
1401- merchantConfig .setRequestHost (merchantConfig .getRequestHost ().trim ());
1402-
14031405 if (isMerchantDetails
14041406 && !merchantConfig .getAuthenticationType ().equalsIgnoreCase (GlobalLabelParameters .MUTUALAUTH )) {
1405- String token = authorization .getToken (merchantConfig , method , requestBody , requestTarget );
1407+ String date = PropertiesUtil .getNewDate ();
1408+ String token = authorization .getToken (merchantConfig , method , requestBody , requestTarget , date );
14061409 if (merchantConfig .getAuthenticationType ().equalsIgnoreCase (GlobalLabelParameters .HTTP )) {
1407-
1408- addDefaultHeader ("Date" , PropertiesUtil .date );
1409- addDefaultHeader ("Host" , merchantConfig .getRequestHost ().trim ());
1410- addDefaultHeader ("v-c-merchant-id" , merchantConfig .getMerchantID ());
1411- addDefaultHeader ("Signature" , token );
1412- addDefaultHeader ("User-Agent" , "Mozilla/5.0" );
1410+ requestHeaderMap .put ("Date" , date );
1411+ requestHeaderMap .put ("Host" , merchantConfig .getRequestHost ().trim ());
1412+ requestHeaderMap .put ("v-c-merchant-id" , merchantConfig .getMerchantID ());
1413+ requestHeaderMap .put ("Signature" , token );
1414+ requestHeaderMap .put ("User-Agent" , "Mozilla/5.0" );
14131415
14141416 if (method .equalsIgnoreCase ("POST" ) || method .equalsIgnoreCase ("PUT" )
14151417 || method .equalsIgnoreCase ("PATCH" )) {
14161418 PayloadDigest payloadDigest = new PayloadDigest (requestBody );
14171419 String digest = payloadDigest .getDigest ();
1418- addDefaultHeader ("Digest" , digest );
1420+ requestHeaderMap . put ("Digest" , digest );
14191421 }
14201422
14211423 } else if (merchantConfig .getAuthenticationType ().equalsIgnoreCase (GlobalLabelParameters .JWT )) {
14221424 token = "Bearer " + token ;
1423- addDefaultHeader ("Authorization" , token );
1425+ requestHeaderMap . put ("Authorization" , token );
14241426 } else if (merchantConfig .getAuthenticationType ().equalsIgnoreCase (GlobalLabelParameters .OAUTH )) {
14251427 token = "Bearer " + token ;
1426- addDefaultHeader ("Authorization" , token );
1428+ requestHeaderMap . put ("Authorization" , token );
14271429 }
14281430 }
14291431
14301432 if (versionInfo != null && !versionInfo .isEmpty ()) {
1431- addDefaultHeader ("v-c-client-id" , "cybs-rest-sdk-java-" + versionInfo );
1433+ requestHeaderMap . put ("v-c-client-id" , "cybs-rest-sdk-java-" + versionInfo );
14321434 }
14331435
14341436 } catch (ConfigException e ) {
0 commit comments