package com.armstrongconsulting.acprotasks.client;

import com.sun.istack.NotNull;

import feign.Feign;
import feign.Logger;
import feign.httpclient.ApacheHttpClient;
import feign.jackson.jaxb.JacksonJaxbJsonDecoder;
import feign.jackson.jaxb.JacksonJaxbJsonEncoder;

public class AcproConnector
{
    private static AcproClient client;

    public static AcproClient getClient(@NotNull String url)
    {
        if (client != null)
        {
            return client;
        }

        return Feign.builder()
            .client(new ApacheHttpClient())
            .encoder(new JacksonJaxbJsonEncoder())
            .decoder(new JacksonJaxbJsonDecoder())
            .logger(new Logger.JavaLogger(AcproClient.class))
            .logLevel(Logger.Level.FULL)
            .target(AcproClient.class, url);
    }
}
