// Path: src/main/java/com/verifalia/api/exceptions/EndpointServerErrorException.java
// public class EndpointServerErrorException extends VerifaliaException {
//     public EndpointServerErrorException(String errorMessage) {
//         super(errorMessage);
//     }
// }
// 
// Path: src/main/java/com/verifalia/api/exceptions/ServiceUnreachableException.java
// public class ServiceUnreachableException extends VerifaliaException {
//     public ServiceUnreachableException(String errorMessage) {
//         super(errorMessage);
//     }
// }
// 
// Path: src/main/java/com/verifalia/api/exceptions/VerifaliaException.java
// public class VerifaliaException extends Exception {
//     private RestResponse response;
// 
//     public VerifaliaException(@NonNull final RestResponse response) {
//         super(response.getStatusCode() + ": " + response.readAsString());
//         this.response = response;
//     }
// 
//     public VerifaliaException(String errorMessage) {
//         super(errorMessage);
//     }
// 
//     public VerifaliaException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/com/verifalia/api/rest/security/AuthenticationProvider.java
// @Getter
// @Setter
// public abstract class AuthenticationProvider {
//     public void decorateRequest(RestClient client, HttpRequestBase request) throws VerifaliaException {
//     }
// 
//     public CloseableHttpClient buildClient(RestClient client) throws IOException {
//         return HttpClients.createDefault();
//     }
// }


import com.verifalia.api.exceptions.EndpointServerErrorException;
import com.verifalia.api.exceptions.ServiceUnreachableException;
import com.verifalia.api.exceptions.VerifaliaException;
import com.verifalia.api.rest.security.AuthenticationProvider;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import org.apache.http.HttpHeaders;
import org.apache.http.client.methods.*;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import static java.util.Objects.nonNull;
/*
 * Verifalia - Email list cleaning and real-time email verification service
 * https://verifalia.com/
 * support@verifalia.com
 *
 * Copyright (c) 2005-2020 Cobisi Research
 *
 * Cobisi Research
 * Via Prima Strada, 35
 * 35129, Padova
 * Italy - European Union
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.verifalia.api.rest;




/***
 * Represents the internal REST client used by the SDK.
 */
public class RestClient {
    private final List<URI> baseURIs;
    private final String apiVersion;
    private final String userAgent;
    private final AuthenticationProvider defaultAuthenticationProvider;
    private int currentBaseURIIndex;

    public RestClient(@NonNull final AuthenticationProvider defaultAuthenticationProvider, @NonNull final List<URI> baseURIs, @NonNull final String apiVersion) {
        this.baseURIs = baseURIs;
        this.apiVersion = apiVersion;
        this.userAgent = getUserAgent();
        this.defaultAuthenticationProvider = defaultAuthenticationProvider;
    }

// Path: src/main/java/com/verifalia/api/exceptions/EndpointServerErrorException.java
// public class EndpointServerErrorException extends VerifaliaException {
//     public EndpointServerErrorException(String errorMessage) {
//         super(errorMessage);
//     }
// }
// 
// Path: src/main/java/com/verifalia/api/exceptions/ServiceUnreachableException.java
// public class ServiceUnreachableException extends VerifaliaException {
//     public ServiceUnreachableException(String errorMessage) {
//         super(errorMessage);
//     }
// }
// 
// Path: src/main/java/com/verifalia/api/exceptions/VerifaliaException.java
// public class VerifaliaException extends Exception {
//     private RestResponse response;
// 
//     public VerifaliaException(@NonNull final RestResponse response) {
//         super(response.getStatusCode() + ": " + response.readAsString());
//         this.response = response;
//     }
// 
//     public VerifaliaException(String errorMessage) {
//         super(errorMessage);
//     }
// 
//     public VerifaliaException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/com/verifalia/api/rest/security/AuthenticationProvider.java
// @Getter
// @Setter
// public abstract class AuthenticationProvider {
//     public void decorateRequest(RestClient client, HttpRequestBase request) throws VerifaliaException {
//     }
// 
//     public CloseableHttpClient buildClient(RestClient client) throws IOException {
//         return HttpClients.createDefault();
//     }
// }


// Path: src/main/java/com/verifalia/api/rest/RestClient.java
import com.verifalia.api.exceptions.EndpointServerErrorException;
import com.verifalia.api.exceptions.ServiceUnreachableException;
import com.verifalia.api.exceptions.VerifaliaException;
import com.verifalia.api.rest.security.AuthenticationProvider;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import org.apache.http.HttpHeaders;
import org.apache.http.client.methods.*;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import static java.util.Objects.nonNull;

/*
 * Verifalia - Email list cleaning and real-time email verification service
 * https://verifalia.com/
 * support@verifalia.com
 *
 * Copyright (c) 2005-2020 Cobisi Research
 *
 * Cobisi Research
 * Via Prima Strada, 35
 * 35129, Padova
 * Italy - European Union
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.verifalia.api.rest;




/***
 * Represents the internal REST client used by the SDK.
 */
public class RestClient {
    private final List<URI> baseURIs;
    private final String apiVersion;
    private final String userAgent;
    private final AuthenticationProvider defaultAuthenticationProvider;
    private int currentBaseURIIndex;

    public RestClient(@NonNull final AuthenticationProvider defaultAuthenticationProvider, @NonNull final List<URI> baseURIs, @NonNull final String apiVersion) {
        this.baseURIs = baseURIs;
        this.apiVersion = apiVersion;
        this.userAgent = getUserAgent();
        this.defaultAuthenticationProvider = defaultAuthenticationProvider;
    }

    public RestResponse execute(@NonNull final RestRequest request) throws VerifaliaException {