test

 avatar
unknown
java
3 years ago
785 B
5
Indexable
@Override
    public Mono<CustomerDTO> getCustomerInfo(String email) {
        var credentials = applicationProperties.getIntegration().getPtDealerPortal().getCredentials();

        return
            Flux.fromIterable(credentials)
                .flatMap(credential -> retrieveCustomerInfo(email, credential.getBasePath(), credential.getApiKey()))
        .next();


    }


    private Mono<CustomerDTO> retrieveCustomerInfo(String email, String basePath, String apiKey){
        final Map<String, String> userIdVariable = Map.of("userId", email);

        return this.webClient
            .get()
            .uri(basePath, userIdVariable)
            .header(HttpHeaders.AUTHORIZATION, "ApiKey " + apiKey)
            .retrieve()
            .bodyToMono(CustomerDTO.class);
    }
Editor is loading...