Skip to content

Commit

Permalink
Merge pull request #133 from smartcar/lock-status
Browse files Browse the repository at this point in the history
feat: get VehicleLockStatus
  • Loading branch information
wikiadrian authored Sep 6, 2023
2 parents 8158ae5 + 99bc61d commit cf00588
Show file tree
Hide file tree
Showing 14 changed files with 511 additions and 11 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ The recommended method for obtaining the SDK is via Gradle or Maven through the

### Gradle
```groovy
compile "com.smartcar.sdk:java-sdk:3.7.0"
compile "com.smartcar.sdk:java-sdk:3.8.0"
```

### Maven
```xml
<dependency>
<groupId>com.smartcar.sdk</groupId>
<artifactId>java-sdk</artifactId>
<version>3.7.0</version>
<version>3.8.0</version>
</dependency>
```

### Jar Direct Download
* [java-sdk-3.7.0.jar](https://search.maven.org/remotecontent?filepath=com/smartcar/sdk/java-sdk/3.7.0/java-sdk-3.7.0.jar)
* [java-sdk-3.7.0-sources.jar](https://search.maven.org/remotecontent?filepath=com/smartcar/sdk/java-sdk/3.7.0/java-sdk-3.7.0-sources.jar)
* [java-sdk-3.7.0-javadoc.jar](https://search.maven.org/remotecontent?filepath=com/smartcar/sdk/java-sdk/3.7.0/java-sdk-3.7.0-javadoc.jar)
* [java-sdk-3.8.0.jar](https://search.maven.org/remotecontent?filepath=com/smartcar/sdk/java-sdk/3.8.0/java-sdk-3.8.0.jar)
* [java-sdk-3.8.0-sources.jar](https://search.maven.org/remotecontent?filepath=com/smartcar/sdk/java-sdk/3.8.0/java-sdk-3.8.0-sources.jar)
* [java-sdk-3.8.0-javadoc.jar](https://search.maven.org/remotecontent?filepath=com/smartcar/sdk/java-sdk/3.8.0/java-sdk-3.8.0-javadoc.jar)

Signatures and other downloads available at [Maven Central](https://search.maven.org/artifact/com.smartcar.sdk/java-sdk/3.7.0/jar).
Signatures and other downloads available at [Maven Central](https://search.maven.org/artifact/com.smartcar.sdk/java-sdk/3.8.0/jar).

## Usage

Expand Down Expand Up @@ -136,5 +136,5 @@ In accordance with the Semantic Versioning specification, the addition of suppor
[ci-url]: https://travis-ci.com/smartcar/java-sdk
[coverage-image]: https://codecov.io/gh/smartcar/java-sdk/branch/master/graph/badge.svg?token=nZAITx7w3X
[coverage-url]: https://codecov.io/gh/smartcar/java-sdk
[javadoc-image]: https://img.shields.io/badge/javadoc-3.7.0-brightgreen.svg
[javadoc-image]: https://img.shields.io/badge/javadoc-3.8.0-brightgreen.svg
[javadoc-url]: https://smartcar.github.io/java-sdk
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
libGroup=com.smartcar.sdk
libName=java-sdk
libVersion=3.7.0
libVersion=3.8.0
libDescription=Smartcar Java SDK
9 changes: 6 additions & 3 deletions src/integration/java/com/smartcar/sdk/SmartcarTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
public class SmartcarTest {
private String accessToken;
private VehicleIds vehicleIds;
private String clientId = System.getenv("E2E_SMARTCAR_CLIENT_ID");
private String clientSecret = System.getenv("E2E_SMARTCAR_CLIENT_SECRET");
private String amt = System.getenv("E2E_SMARTCAR_AMT");
private String clientId;
private String clientSecret;
private String amt;
private AuthClient client;
private String authorizeUrl;
private String[] scope = {"read_odometer"};
Expand All @@ -27,6 +27,9 @@ public void beforeSuite() throws Exception {
this.accessToken = client.exchangeCode(code).getAccessToken();
VehicleIds vehicleIds = Smartcar.getVehicles(this.accessToken);
this.vehicleIds = vehicleIds;
this.clientId = AuthHelpers.getClientId();
this.clientSecret = AuthHelpers.getClientSecret();
this.amt = AuthHelpers.getApplicationManagementToken();
}

@Test
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/smartcar/sdk/Vehicle.java
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,16 @@ public ActionResponse stopCharge() throws SmartcarException {
return this.call("charge", "POST", body, ActionResponse.class);
}

/**
* Send request to the /security endpoint to get the vehicle's lock status
*
* @return VehicleLockStatus
* @throws SmartcarException
*/
public VehicleLockStatus lockStatus() throws SmartcarException {
return this.call("security", "GET", null, VehicleLockStatus.class);
}

/**
* Subscribe vehicle to a webhook
*
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/smartcar/sdk/data/BatchResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,17 @@ public VehicleChargeLimit chargeLimit()
return get("/charge/limit", VehicleChargeLimit.class);
}

/**
* Get response from the /security endpoint
*
* @return the lock status of the vehicle
* @throws SmartcarException if the request for this endpoint returned an HTTP error code
*/
public VehicleLockStatus lockStatus()
throws SmartcarException {
return get("/security", VehicleLockStatus.class);
}

/** @return a stringified representation of BatchResponse */
@Override
public String toString() {
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/com/smartcar/sdk/data/VehicleChargingPort.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.smartcar.sdk.data;

public class VehicleChargingPort extends ApiData {
private String type;
private String status;

/**
* Returns the charging port type
*
* @return charging port type
*/
public String getType() {
return this.type;
}

/**
* Returns the charging port status
*
* @return charging port status
*/
public String getStatus() {
return this.status;
}

/**
* @return a stringified representation of VehicleChargingPort
*/
@Override
public String toString() {
return this.getClass().getName() + "{" + "type=" + type + ", status=" + status + '}';
}
}
32 changes: 32 additions & 0 deletions src/main/java/com/smartcar/sdk/data/VehicleDoor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.smartcar.sdk.data;

public class VehicleDoor extends ApiData {
private String type;
private String status;

/**
* Returns the door type
*
* @return door type
*/
public String getType() {
return this.type;
}

/**
* Returns the door status
*
* @return door status
*/
public String getStatus() {
return this.status;
}

/**
* @return a stringified representation of VehicleDoor
*/
@Override
public String toString() {
return this.getClass().getName() + "{" + "type=" + type + ", status=" + status + '}';
}
}
83 changes: 83 additions & 0 deletions src/main/java/com/smartcar/sdk/data/VehicleLockStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.smartcar.sdk.data;

import java.util.Arrays;

public class VehicleLockStatus extends ApiData {
private boolean isLocked;
private VehicleDoor[] doors;
private VehicleWindow[] windows;
private VehicleStorage[] storage;
private VehicleSunroof[] sunroof;
private VehicleChargingPort[] chargingPort;

/**
* Check if the vehicle currently locked.
*
* @return {boolean} True if the vehicle is locked, otherwise false.
*/
public boolean isLocked() {
return this.isLocked;
}

/**
* Returns the vehicle doors
*
* @return vehicle doors
*/
public VehicleDoor[] getDoors() {
return this.doors;
}

/**
* Returns the vehicle's windows
*
* @return vehicle windows
*/
public VehicleWindow[] getWindows() {
return this.windows;
}

/**
* Returns the vehicle's storage
*
* @return vehicle storage
*/
public VehicleStorage[] getStorage() {
return this.storage;
}

/**
* Returns the vehicle's sunroofs
*
* @return vehicle sunroof
*/
public VehicleSunroof[] getSunroof() {
return this.sunroof;
}

/**
* Returns the vehicle's charging ports
*
* @return vehicle charging port
*/
public VehicleChargingPort[] getChargingPort() {
return this.chargingPort;
}

/**
* Returns a stringified representation of the VehicleLockStatus object.
*
* @return A string describing the lock status and other vehicle attributes.
*/
@Override
public String toString() {
return this.getClass().getName() + "{" +
"isLocked=" + this.isLocked +
", doors=" + Arrays.toString(this.doors) +
", windows=" + Arrays.toString(this.windows) +
", storage=" + Arrays.toString(this.storage) +
", sunroof=" + Arrays.toString(this.sunroof) +
", chargingPort=" + Arrays.toString(this.chargingPort) +
'}';
}
}
32 changes: 32 additions & 0 deletions src/main/java/com/smartcar/sdk/data/VehicleStorage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.smartcar.sdk.data;

public class VehicleStorage extends ApiData {
private String type;
private String status;

/**
* Returns the storage type
*
* @return storage type
*/
public String getType() {
return this.type;
}

/**
* Returns the storage status
*
* @return storage status
*/
public String getStatus() {
return this.status;
}

/**
* @return a stringified representation of VehicleStorage
*/
@Override
public String toString() {
return this.getClass().getName() + "{" + "type=" + type + ", status=" + status + '}';
}
}
32 changes: 32 additions & 0 deletions src/main/java/com/smartcar/sdk/data/VehicleSunroof.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.smartcar.sdk.data;

public class VehicleSunroof extends ApiData {
private String type;
private String status;

/**
* Returns the sunroof type
*
* @return sunroof type
*/
public String getType() {
return this.type;
}

/**
* Returns the sunroof status
*
* @return sunroof status
*/
public String getStatus() {
return this.status;
}

/**
* @return a stringified representation of VehicleSunroof
*/
@Override
public String toString() {
return this.getClass().getName() + "{" + "type=" + type + ", status=" + status + '}';
}
}
32 changes: 32 additions & 0 deletions src/main/java/com/smartcar/sdk/data/VehicleWindow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.smartcar.sdk.data;

public class VehicleWindow extends ApiData {
private String type;
private String status;

/**
* Returns the window type
*
* @return window type
*/
public String getType() {
return this.type;
}

/**
* Returns the window status
*
* @return window status
*/
public String getStatus() {
return this.status;
}

/**
* @return a stringified representation of VehicleWindow
*/
@Override
public String toString() {
return this.getClass().getName() + "{" + "type=" + type + ", status=" + status + '}';
}
}
Loading

0 comments on commit cf00588

Please sign in to comment.