package com.julienvey.trello.impl.http;

import com.julienvey.trello.TrelloHttpClient;
import com.julienvey.trello.exception.TrelloHttpException;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;

import java.net.URI;

public class RestTemplateHttpClient implements TrelloHttpClient {

    private RestTemplate restTemplate;

    public RestTemplateHttpClient() {
        restTemplate = new RestTemplate();
    }

    @Override
    public <T> T postForObject(String url, T object, Class<T> objectClass, String... params) {
        try {
            return restTemplate.postForObject(url, object, objectClass, params);
        } catch (RestClientException e) {
            throw new TrelloHttpException(e);
        }

    }

    @Override
    public URI postForLocation(String url, Object object, String... params) {
        try {
            return restTemplate.postForLocation(url, object, params);
        } catch (RestClientException e) {
            throw new TrelloHttpException(e);
        }
    }

    @Override
    public <T> T get(String url, Class<T> objectClass, String... params) {
        try {
            return restTemplate.getForObject(url, objectClass, params);
        } catch (RestClientException e) {
            throw new TrelloHttpException(e);
        }
    }

    @Override
    public <T> T putForObject(String url, T object, Class<T> objectClass, String... params) {
        try {
            return restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<>(object), objectClass, params).getBody();
        } catch (RestClientException e) {
            throw new TrelloHttpException(e);
        }
    }
}

@@ -742,32 +742,43 @@
 ct, objectClass,
+ (Object%5B%5D)
  params);%0A      
@@ -763,32 +763,32 @@
 ect%5B%5D) params);%0A
-
         %7D catch 
@@ -865,25 +865,24 @@
 ;%0A        %7D%0A
-%0A
     %7D%0A%0A    @
@@ -1042,16 +1042,27 @@
  object,
+ (Object%5B%5D)
  params)
@@ -1325,32 +1325,43 @@
 rl, objectClass,
+ (Object%5B%5D)
  params);%0A      
@@ -1682,23 +1682,55 @@
 tClass, 
-params)
+(Object%5B%5D) params)%0A                    
 .getBody

Fix compiler warnings about ambiguous varargs invocation