package com.systemincloud.sdk.java;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;

import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.media.multipart.MultiPartFeature;

import com.systemincloud.sdk.java.msg.Credentials;
import com.systemincloud.sdk.java.msg.TestConnectionReq;
import com.systemincloud.sdk.java.msg.TestConnectionRsp;

public class SicClientImpl implements SicClient {

    protected static final String PATH = "api";
    
    protected Credentials credentials;
    
    protected WebTarget service;
    
    public SicClientImpl(String accountNumber, String systemName, String systemKey) {
        this.credentials = new Credentials(accountNumber, systemName, systemKey);
        this.service = initRestClient();
    }

    private WebTarget initRestClient() {
        ClientConfig config = new ClientConfig();
        config.register(MultiPartFeature.class);
        Client client = ClientBuilder.newBuilder()
                                     .withConfig(config)
                                     .build();
        return client.target("https://connector.systemincloud.com");
    }

    @Override public TestConnectionRsp testConnection() {
        TestConnectionRsp ret;
        try {
            ret = service.path(PATH).path(TestConnectionReq.class.toString().toLowerCase()).request(MediaType.APPLICATION_JSON)
                                                                            .post(Entity.entity(new TestConnectionReq(credentials), MediaType.APPLICATION_JSON), TestConnectionRsp.class);
        } catch(Exception e) { ret = new TestConnectionRsp(false, e.getMessage()); }
        return ret;
    }
}

@@ -1408,21 +1408,23 @@
 H).path(
-TestC
+%22test-c
 onnectio
@@ -1428,42 +1428,9 @@
 tion
-Req.class.toString().toLowerCase()
+%22
 ).re
@@ -1463,32 +1463,16 @@
 N_JSON)%0A
-                
         

Fix api name of test connection