// Path: teslaapi/src/main/java/com/eleks/tesla/api/auth/AuthCredentials.java
// public class AuthCredentials {
//     public final String secret;
//     public final String username;
// 
//     public AuthCredentials(String userName, String secret) {
//         this.username = userName;
//         this.secret = secret;
//     }
// }
// 
// Path: teslaapi/src/main/java/com/eleks/tesla/api/auth/OAuthModule.java
// public class OAuthModule extends AuthModule {
//     public OAuthModule() {
//     }
// 
//     public void authorizeRequest(HttpUriRequest httpurirequest, AuthCredentials authcredentials) {
//         if (authcredentials != null) {
//             httpurirequest.addHeader(new BasicHeader("Authorization", String.format("Bearer %s", authcredentials.secret)));
//         }
//     }
// }
// 
// Path: teslaapi/src/main/java/com/eleks/tesla/api/decoder/JsonObjectEntityDecoder.java
// public class JsonObjectEntityDecoder extends EntityDecoder {
//     public Object decodeEntity(HttpEntity httpentity) throws JSONException {
//         JSONObject jsonobject = null;
//         String jsonString;
//         if (httpentity == null) {
//             return null;
//         }
//         try {
//             jsonString = EntityUtils.toString(httpentity).trim();
//         } catch (Exception e) {
//             Log.e("JsonObjectEntityDecoder", "decodeEntity", e);
//             return null;
//         }
//         if (!jsonString.isEmpty()) {
//             jsonobject = new JSONObject(jsonString);
//         }
//         return jsonobject;
//     }
// }
// 
// Path: teslaapi/src/main/java/com/eleks/tesla/api/exception/TeslaApiException.java
// public class TeslaApiException extends Exception {
// 
//     public static TeslaApiException fromCode(int code) {
//         switch (code) {
//             case HttpStatus.AUTH_CODE:
//                 return new NonAuthrizedException();
//         }
//         return new TeslaApiException();
//     }
// 
//     public TeslaApiException() {
//     }
// 
//     public TeslaApiException(String detailMessage) {
//         super(detailMessage);
//     }
// 
//     public TeslaApiException(String detailMessage, Throwable throwable) {
//         super(detailMessage, throwable);
//     }
// 
//     public TeslaApiException(Throwable throwable) {
//         super(throwable);
//     }
// }


import android.os.Build;
import com.eleks.tesla.api.auth.AuthCredentials;
import com.eleks.tesla.api.auth.OAuthModule;
import com.eleks.tesla.api.decoder.JsonObjectEntityDecoder;
import com.eleks.tesla.api.exception.TeslaApiException;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.security.KeyStore;
import java.util.Locale;
import java.util.Map;
            JSONObject jsonobject = new JSONObject();
            jsonobject.put("state", "close");
            return sendVehicleCommand(vehicleId, "sun_roof_control", jsonobject, authcredentials);
        } catch (JSONException e) {
            throw new TeslaApiException(e);
        }
    }

    public JSONObject openSunroof(long vehicleId, AuthCredentials authcredentials) throws TeslaApiException {
        try {
            JSONObject jsonobject = new JSONObject();
            jsonobject.put("state", "open");
            return sendVehicleCommand(vehicleId, "sun_roof_control", jsonobject, authcredentials);
        } catch (JSONException e) {
            throw new TeslaApiException(e);
        }
    }

    public JSONObject getDriveState(long vehicleId, AuthCredentials authcredentials) throws TeslaApiException {
        return sendVehicleDataRequest(vehicleId, "drive_state", null, authcredentials);
    }

    public JSONObject getClimateState(long vehicleId, AuthCredentials authcredentials) throws TeslaApiException {
        return sendVehicleDataRequest(vehicleId, "climate_state", null, authcredentials);
    }

    public JSONObject flashLights(long vehicleId, AuthCredentials authcredentials) throws TeslaApiException {
        return sendVehicleCommand(vehicleId, "flash_lights", null, authcredentials);
    }

// Path: teslaapi/src/main/java/com/eleks/tesla/api/auth/AuthCredentials.java
// public class AuthCredentials {
//     public final String secret;
//     public final String username;
// 
//     public AuthCredentials(String userName, String secret) {
//         this.username = userName;
//         this.secret = secret;
//     }
// }
// 
// Path: teslaapi/src/main/java/com/eleks/tesla/api/auth/OAuthModule.java
// public class OAuthModule extends AuthModule {
//     public OAuthModule() {
//     }
// 
//     public void authorizeRequest(HttpUriRequest httpurirequest, AuthCredentials authcredentials) {
//         if (authcredentials != null) {
//             httpurirequest.addHeader(new BasicHeader("Authorization", String.format("Bearer %s", authcredentials.secret)));
//         }
//     }
// }
// 
// Path: teslaapi/src/main/java/com/eleks/tesla/api/decoder/JsonObjectEntityDecoder.java
// public class JsonObjectEntityDecoder extends EntityDecoder {
//     public Object decodeEntity(HttpEntity httpentity) throws JSONException {
//         JSONObject jsonobject = null;
//         String jsonString;
//         if (httpentity == null) {
//             return null;
//         }
//         try {
//             jsonString = EntityUtils.toString(httpentity).trim();
//         } catch (Exception e) {
//             Log.e("JsonObjectEntityDecoder", "decodeEntity", e);
//             return null;
//         }
//         if (!jsonString.isEmpty()) {
//             jsonobject = new JSONObject(jsonString);
//         }
//         return jsonobject;
//     }
// }
// 
// Path: teslaapi/src/main/java/com/eleks/tesla/api/exception/TeslaApiException.java
// public class TeslaApiException extends Exception {
// 
//     public static TeslaApiException fromCode(int code) {
//         switch (code) {
//             case HttpStatus.AUTH_CODE:
//                 return new NonAuthrizedException();
//         }
//         return new TeslaApiException();
//     }
// 
//     public TeslaApiException() {
//     }
// 
//     public TeslaApiException(String detailMessage) {
//         super(detailMessage);
//     }
// 
//     public TeslaApiException(String detailMessage, Throwable throwable) {
//         super(detailMessage, throwable);
//     }
// 
//     public TeslaApiException(Throwable throwable) {
//         super(throwable);
//     }
// }


// Path: teslaapi/src/main/java/com/eleks/tesla/api/TeslaApi.java
import android.os.Build;
import com.eleks.tesla.api.auth.AuthCredentials;
import com.eleks.tesla.api.auth.OAuthModule;
import com.eleks.tesla.api.decoder.JsonObjectEntityDecoder;
import com.eleks.tesla.api.exception.TeslaApiException;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.security.KeyStore;
import java.util.Locale;
import java.util.Map;

            JSONObject jsonobject = new JSONObject();
            jsonobject.put("state", "close");
            return sendVehicleCommand(vehicleId, "sun_roof_control", jsonobject, authcredentials);
        } catch (JSONException e) {
            throw new TeslaApiException(e);
        }
    }

    public JSONObject openSunroof(long vehicleId, AuthCredentials authcredentials) throws TeslaApiException {
        try {
            JSONObject jsonobject = new JSONObject();
            jsonobject.put("state", "open");
            return sendVehicleCommand(vehicleId, "sun_roof_control", jsonobject, authcredentials);
        } catch (JSONException e) {
            throw new TeslaApiException(e);
        }
    }

    public JSONObject getDriveState(long vehicleId, AuthCredentials authcredentials) throws TeslaApiException {
        return sendVehicleDataRequest(vehicleId, "drive_state", null, authcredentials);
    }

    public JSONObject getClimateState(long vehicleId, AuthCredentials authcredentials) throws TeslaApiException {
        return sendVehicleDataRequest(vehicleId, "climate_state", null, authcredentials);
    }

    public JSONObject flashLights(long vehicleId, AuthCredentials authcredentials) throws TeslaApiException {
        return sendVehicleCommand(vehicleId, "flash_lights", null, authcredentials);
    }

    public JSONObject getChargeState(long vehicleId, AuthCredentials authcredentials) throws TeslaApiException {