//Import required classes
import java.util.Map;

import com.microsoft.azure.sdk.iot.device.IotHubEventCallback;
import com.microsoft.azure.sdk.iot.device.IotHubStatusCode;
import sdk.dao.d2c.CloudResponse;
import sdk.service.IoTConnectSDK;
import sdk.service.IoTConnectSDKImpl;
import sdk.service.SDKCallback;
import sdk.service.TwinCallback;

//Sample Class
public class Sample {
   public static void main(String[] args) throws Exception {
      CBImplementor cb = new CBImplementor();
      String env = "<<env>>";  //Replace your environment here
      String uniqueId = "<<uniqueId>>";  //Replace device uniqueid here
      String cpId = "<<cpid>>";  //Replace CPID here
      IoTConnectSDK ioTConnectSDK = new IoTConnectSDKImpl(cpId, uniqueId, env, cb, cb);
      ioTConnectSDK.sendData("[{'data':{'humidity':'1211'},'time':'2020-02-28T10:49:37.658Z','uniqueId':'<<uniqueId>>'}]"); // Replace device uniqueid here
   }
}
//Callback class
class CBImplementor implements SDKCallback, TwinCallback, IotHubEventCallback {
    @Override
    public void sdkCallbackMethod(CloudResponse cloudResponse) {
        // TODO : sdkCallbackMethod
    }

    @Override
    public void execute(IotHubStatusCode responseStatus, Object callbackContext) {
        // TODO : IotHubEventCallback
    }

    @Override
    public void twinCallBackMethod(Map<String, String> arg0) {
        if(arg0.size() > 0){
            System.out.println(arg0.toString());
            System.out.println("Twin Property Updated");
        }
    }
}