diff --git a/README.md b/README.md index 39be785d..14cdd7c0 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The recommended method for obtaining the SDK is via Gradle or Maven through the ### Gradle ```groovy -compile "com.smartcar.sdk:java-sdk:4.2.0" +compile "com.smartcar.sdk:java-sdk:4.3.0" ``` ### Maven @@ -18,16 +18,16 @@ compile "com.smartcar.sdk:java-sdk:4.2.0" com.smartcar.sdk java-sdk - 4.2.0 + 4.3.0 ``` ### Jar Direct Download -* [java-sdk-4.2.0.jar](https://repo1.maven.org/maven2/com/smartcar/sdk/java-sdk/4.2.0/java-sdk-4.2.0.jar) -* [java-sdk-4.2.0-sources.jar](https://repo1.maven.org/maven2/com/smartcar/sdk/java-sdk/4.2.0/java-sdk-4.2.0-sources.jar) -* [java-sdk-4.2.0-javadoc.jar](https://repo1.maven.org/maven2/com/smartcar/sdk/java-sdk/4.2.0/java-sdk-4.2.0-javadoc.jar) +* [java-sdk-4.3.0.jar](https://repo1.maven.org/maven2/com/smartcar/sdk/java-sdk/4.3.0/java-sdk-4.3.0.jar) +* [java-sdk-4.3.0-sources.jar](https://repo1.maven.org/maven2/com/smartcar/sdk/java-sdk/4.3.0/java-sdk-4.3.0-sources.jar) +* [java-sdk-4.3.0-javadoc.jar](https://repo1.maven.org/maven2/com/smartcar/sdk/java-sdk/4.3.0/java-sdk-4.3.0-javadoc.jar) -Signatures and other downloads available at [Maven Central](https://central.sonatype.com/artifact/com.smartcar.sdk/java-sdk/4.2.0). +Signatures and other downloads available at [Maven Central](https://central.sonatype.com/artifact/com.smartcar.sdk/java-sdk/4.3.0). ## Usage @@ -136,7 +136,7 @@ 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-4.2.0-brightgreen.svg +[javadoc-image]: https://img.shields.io/badge/javadoc-4.3.0-brightgreen.svg [javadoc-url]: https://smartcar.github.io/java-sdk [maven-image]: https://img.shields.io/maven-central/v/com.smartcar.sdk/java-sdk.svg?label=Maven%20Central [maven-url]: https://central.sonatype.com/artifact/com.smartcar.sdk/java-sdk diff --git a/gradle.properties b/gradle.properties index 0ea6111c..48e39d9e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ libGroup=com.smartcar.sdk libName=java-sdk -libVersion=4.2.0 +libVersion=4.3.0 libDescription=Smartcar Java SDK diff --git a/src/main/java/com/smartcar/sdk/SmartcarException.java b/src/main/java/com/smartcar/sdk/SmartcarException.java index be57ed20..4dddf225 100644 --- a/src/main/java/com/smartcar/sdk/SmartcarException.java +++ b/src/main/java/com/smartcar/sdk/SmartcarException.java @@ -22,6 +22,7 @@ public class SmartcarException extends java.lang.Exception { private final String docURL; private final String requestId; private final int retryAfter; + private final String suggestedUserMessage; public static class Builder { private int statusCode; @@ -34,6 +35,7 @@ public static class Builder { private String docURL; private String requestId; private int retryAfter; + private String suggestedUserMessage; public Builder() { this.statusCode = 0; @@ -46,6 +48,7 @@ public Builder() { this.docURL = ""; this.requestId = ""; this.retryAfter = 0; + this.suggestedUserMessage = ""; } public Builder statusCode(int statusCode) { @@ -98,6 +101,11 @@ public Builder retryAfter(int retryAfter) { return this; } + public Builder suggestedUserMessage(String suggestedUserMessage) { + this.suggestedUserMessage = suggestedUserMessage; + return this; + } + public SmartcarException build() { return new SmartcarException(this); } } @@ -112,6 +120,7 @@ private SmartcarException(Builder builder) { this.docURL = builder.docURL; this.requestId = builder.requestId; this.retryAfter = builder.retryAfter; + this.suggestedUserMessage = builder.suggestedUserMessage; } public static SmartcarException Factory(final int statusCode, JsonObject headers, JsonObject body) { @@ -187,6 +196,10 @@ public static SmartcarException Factory(final int statusCode, JsonObject headers builder.retryAfter(retryAfter.getAsInt()); } + if (bodyJson.has("suggestedUserMessage")) { + builder.suggestedUserMessage(bodyJson.get("suggestedUserMessage").getAsString()); + } + return builder.build(); } @@ -299,6 +312,15 @@ public JsonArray getDetail() { return this.detail; } + /** + * Returns the suggested user message if available for this exception. + * + * @return the suggested user message + */ + public String getSuggestedUserMessage() { + return this.suggestedUserMessage; + } + /** * Returns the retry-after unix timestamp (ms) upon hitting a rate limit error. * diff --git a/src/test/java/com/smartcar/sdk/VehicleTest.java b/src/test/java/com/smartcar/sdk/VehicleTest.java index 34ab9643..ce8125b1 100644 --- a/src/test/java/com/smartcar/sdk/VehicleTest.java +++ b/src/test/java/com/smartcar/sdk/VehicleTest.java @@ -572,6 +572,7 @@ public void testV2RateLimitError() throws FileNotFoundException { thrown = true; Assert.assertEquals(ex.getStatusCode(), 429); Assert.assertEquals(ex.getRetryAfter(), 12345); + Assert.assertEquals(ex.getSuggestedUserMessage(), "Your vehicle is temporarily unable to connect to KabobMobile. Please be patient while we’re working to resolve this issue."); } Assert.assertTrue(thrown); diff --git a/src/test/resources/ErrorVehicleRateLimit.json b/src/test/resources/ErrorVehicleRateLimit.json index 985eed0b..b8374825 100644 --- a/src/test/resources/ErrorVehicleRateLimit.json +++ b/src/test/resources/ErrorVehicleRateLimit.json @@ -7,5 +7,6 @@ "requestId": "5dea93a1-3f79-4246-90c5-89610a20471b", "resolution": { "type": "RETRY_LATER" - } + }, + "suggestedUserMessage": "Your vehicle is temporarily unable to connect to KabobMobile. Please be patient while we’re working to resolve this issue." }