diff --git a/README.md b/README.md index 0807ba2..79cbf36 100644 --- a/README.md +++ b/README.md @@ -11,17 +11,17 @@ See https://www.semantics3.com for more information. com.semantics3 Sem3Java - 1.2.2 + 1.2.4 ``` -* For projects which don't use Maven each stable [release](https://github.com/Semantics3/semantics3-java/releases/download/Sem3Java-1.2.2/Sem3Java-1.2.2-jar-with-dependencies.jar) is also available as a fat jar. +* For projects which don't use Maven each stable [release](https://github.com/Semantics3/semantics3-java/releases/download/Sem3Java-1.2.4/Sem3Java-1.2.4-jar-with-dependencies.jar) is also available as a fat jar. ## Getting Started In order to use the client, you must have both an API key and an API secret. To obtain your key and secret, you need to first create an account at https://www.semantics3.com/ -You can access your API access credentials from the user dashboard at https://www.semantics3.com/dashboard/applications +You can access your API access credentials from the user dashboard at https://dashboard.semantics3.com. ### Setup Work diff --git a/pom.xml b/pom.xml index a300dd7..cea89bf 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.semantics3 Sem3Java - 1.2.3 + 1.2.5-SNAPSHOT Semantics3 Java Library https://github.com/Semantics3/semantics3-java Java bindings for Semantics3 API @@ -147,7 +147,7 @@ scm:git:git://github.com/Semantics3/semantics3-java.git scm:git:git@github.com:Semantics3/semantics3-java.git https://github.com/Semantics3/semantics3-java - Sem3Java-1.2.3 + HEAD diff --git a/src/main/java/com/semantics3/api/Semantics3Request.java b/src/main/java/com/semantics3/api/Semantics3Request.java index c5cce25..f3c3b87 100644 --- a/src/main/java/com/semantics3/api/Semantics3Request.java +++ b/src/main/java/com/semantics3/api/Semantics3Request.java @@ -99,7 +99,13 @@ protected JSONObject fetch(String endpoint, String params) throws catch (IOException e) { InputStream error = ((HttpURLConnection) request).getErrorStream(); JSONObject json = new JSONObject(new JSONTokener(error)); - json.put("code", "Error"); + if (!json.has("code")) { + json.put("code", "Error"); + } + else { + Object value = json.get("code"); + json.put("code", value.toString()); + } return json; } } @@ -145,7 +151,13 @@ protected JSONObject fetch(String endpoint, String method, HashMap 0, is(true)); - } - - @Test + .categoriesField("cat_id", 4992); JSONObject results = products.getCategories(); JSONArray resultsArray = (JSONArray) results.get("results"); assertThat(resultsArray.length() > 0, is(true)); } @Test public void TestSKUQuery() throws OAuthExpectationFailedException, OAuthCommunicationException, OAuthMessageSignerException, IOException, URISyntaxException { Properties property = TestUtils.getConfig("api.config"); Semantics3Request semantics3Request = new Semantics3Request(property.get("API_KEY").toString(), property.get("API_SECRET").toString()); @@ -85,6 +80,14 @@ public void TestSKUQuery() throws OAuthExpectationFailedException, OAuthCommunic assertThat(resultsArray.length() > 0, is(true)); } + @Test(expected = Semantics3Exception.class) + public void TestSiteQuery() throws IOException, OAuthExpectationFailedException, OAuthCommunicationException, OAuthMessageSignerException, URISyntaxException { + Properties property = TestUtils.getConfig("api.config"); + Products products = new Products(property.get("API_KEY").toString(), property.get("API_SECRET").toString()); + products .productsField("url", "zsdfseobn.com/sdgeafg"); + JSONObject results = products.getProducts(); + } + @Ignore public void TestPagination() throws IOException, OAuthCommunicationException, OAuthExpectationFailedException, OAuthMessageSignerException, URISyntaxException { Properties property = TestUtils.getConfig("api.config");