Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
1.3 kB
3
Indexable
    public <T> ResponseEntity<T> exchange(RestServiceUrlInfo engagementEnum, @Nullable Map<String, String> pathParams, @Nullable MultiValueMap<String, String> queryParams, @Nullable Object request, Class<T> classstr, String financialId) throws ApplicationException {
        ResponseEntity<T> response = null;
        pathParams = this.checkLivPathParam(pathParams);
        pathParams = Objects.isNull(pathParams) ? Map.of() : pathParams;
        if (request instanceof HttpEntity<?> entity) {
            ;
        } else {
            entity = new HttpEntity(request);
        }

        ResponseEntity responseEntity;
        try {
            UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl(this.getHostUrl(engagementEnum)).path(engagementEnum.getServiceURL()).queryParams(queryParams).build(false).expand(pathParams);
            HttpHeaders headers = new HttpHeaders();
            if (request != null) {
                headers.addAll(entity.getHeaders());
            }

            headers.addAll(this.constructServiceHeader(financialId));
            return this.getInstance().exchange(uriComponents.toString(), engagementEnum.getMethod(), new HttpEntity(Objects.isNull(request) ? null : entity.getBody(), headers), classstr, new Object[0]);
        } 
Leave a Comment