diff --git a/doc/ProductSearch.md b/doc/ProductSearch.md index b62377d..a4fd920 100644 --- a/doc/ProductSearch.md +++ b/doc/ProductSearch.md @@ -6,7 +6,7 @@ With the release of ViSenze's Catalog system, ViSearch Android SDK will now incl - Aggregate search results on a product level instead of image level - Consistent data type in API response with Catalog’s schema -> Current stable version: 2.2.6 +> Current stable version: 2.3.0 > Minimum Android SDK Version: API 9, Android 2.3 @@ -61,10 +61,11 @@ allprojects { } ``` -include the dependency in your project using gradle: +include the dependency in your project using gradle. Please change the version to latest. + ```gradle implementation 'com.github.visenze:visenze-tracking-android:0.2.2' -implementation 'com.github.visenze:visearch-sdk-android:2.2.6' +implementation 'com.github.visenze:visearch-sdk-android:2.3.0' ``` ### 1.3 Add User Permissions diff --git a/doc/ViSearch.md b/doc/ViSearch.md index a721f11..a8b420d 100644 --- a/doc/ViSearch.md +++ b/doc/ViSearch.md @@ -4,7 +4,7 @@ ViSearch is an API that provides accurate, reliable and scalable image search. V The ViSearch Android SDK is an open source software to provide easy integration of ViSearch Search API with your Android mobile applications. It provides three search methods based on the ViSearch Search API - pre-indexed search, color search and upload search. For source code and references, please visit the [Github Repository](https://github.com/visenze/visearch-sdk-android). ->Current stable version: 2.2.6 +>Current stable version: 2.3.0 >Minimum Android SDK Version: API 9, Android 2.3 @@ -77,10 +77,11 @@ allprojects { } ``` -include the dependency in your project using gradle: +include the dependency in your project using gradle. Please change the version to latest. + ```gradle implementation 'com.github.visenze:visenze-tracking-android:0.2.2' -implementation 'com.github.visenze:visearch-sdk-android:2.2.6' +implementation 'com.github.visenze:visearch-sdk-android:2.3.0' ``` ### 1.3 Add User Permissions diff --git a/visearch-android/build.gradle b/visearch-android/build.gradle index 0663b6a..83e13ba 100644 --- a/visearch-android/build.gradle +++ b/visearch-android/build.gradle @@ -4,9 +4,9 @@ plugins { } def versionMajor = 2 -def versionMinor = 2 -def versionPatch = 6 -version = '2.2.6' +def versionMinor = 3 +def versionPatch = 0 +version = '2.3.0' android { compileSdkVersion 29 diff --git a/visearch-android/src/main/java/com/visenze/visearch/android/IdSearchParams.java b/visearch-android/src/main/java/com/visenze/visearch/android/IdSearchParams.java index 608e51c..0883ad4 100644 --- a/visearch-android/src/main/java/com/visenze/visearch/android/IdSearchParams.java +++ b/visearch-android/src/main/java/com/visenze/visearch/android/IdSearchParams.java @@ -24,6 +24,7 @@ public class IdSearchParams extends SearchParams { private Integer setLimit; private Boolean useSetBasedCtl; + private Boolean showBestProductImages; public IdSearchParams() { super(); @@ -148,6 +149,10 @@ public Map > toMap() { putStringInMap(map, "use_set_based_ctl", useSetBasedCtl.toString()); } + if (showBestProductImages != null) { + putStringInMap(map, "show_best_product_images", showBestProductImages.toString()); + } + return map; } diff --git a/visearch-android/src/main/java/com/visenze/visearch/android/ProductSearchByIdParams.java b/visearch-android/src/main/java/com/visenze/visearch/android/ProductSearchByIdParams.java index 3949e05..4ea4c4d 100644 --- a/visearch-android/src/main/java/com/visenze/visearch/android/ProductSearchByIdParams.java +++ b/visearch-android/src/main/java/com/visenze/visearch/android/ProductSearchByIdParams.java @@ -26,6 +26,9 @@ public class ProductSearchByIdParams extends BaseProductSearchParams { @SerializedName("use_set_based_ctl") private Boolean useSetBasedCtl; + @SerializedName("show_best_product_images") + private Boolean showBestProductImages; + public String getProductId() { return productId; } @@ -82,6 +85,14 @@ public void setUseSetBasedCtl(Boolean useSetBasedCtl) { this.useSetBasedCtl = useSetBasedCtl; } + public Boolean getShowBestProductImages() { + return showBestProductImages; + } + + public void setShowBestProductImages(Boolean showBestProductImages) { + this.showBestProductImages = showBestProductImages; + } + public ProductSearchByIdParams(String productId) { this.productId = productId; } diff --git a/visearch-android/src/main/java/com/visenze/visearch/android/model/BestImage.java b/visearch-android/src/main/java/com/visenze/visearch/android/model/BestImage.java new file mode 100644 index 0000000..b11d67c --- /dev/null +++ b/visearch-android/src/main/java/com/visenze/visearch/android/model/BestImage.java @@ -0,0 +1,41 @@ +package com.visenze.visearch.android.model; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class BestImage implements Serializable { + + @SerializedName("type") + private String type; + + @SerializedName("url") + private String url; + + @SerializedName("index") + private String index; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getIndex() { + return index; + } + + public void setIndex(String index) { + this.index = index; + } +} diff --git a/visearch-android/src/main/java/com/visenze/visearch/android/model/ImageResult.java b/visearch-android/src/main/java/com/visenze/visearch/android/model/ImageResult.java index d3e1b8f..d95da6b 100644 --- a/visearch-android/src/main/java/com/visenze/visearch/android/model/ImageResult.java +++ b/visearch-android/src/main/java/com/visenze/visearch/android/model/ImageResult.java @@ -38,6 +38,9 @@ public class ImageResult { @SerializedName("tags") private Map tags; + @SerializedName("best_images") + private List bestImages; + public ImageResult() { this.fieldList = new HashMap(); } @@ -145,4 +148,12 @@ public Boolean getPinned() { public void setPinned(Boolean pinned) { this.pinned = pinned; } + + public List getBestImages() { + return bestImages; + } + + public void setBestImages(List bestImages) { + this.bestImages = bestImages; + } } diff --git a/visearch-android/src/main/java/com/visenze/visearch/android/model/Product.java b/visearch-android/src/main/java/com/visenze/visearch/android/model/Product.java index 578bb41..ba25f72 100644 --- a/visearch-android/src/main/java/com/visenze/visearch/android/model/Product.java +++ b/visearch-android/src/main/java/com/visenze/visearch/android/model/Product.java @@ -48,6 +48,9 @@ public class Product { @SerializedName("alternatives") private List alternatives; + @SerializedName("best_images") + private List bestImages; + public String getProductId() { return productId; } @@ -156,4 +159,12 @@ public Boolean getPinned() { public void setPinned(Boolean pinned) { this.pinned = pinned; } + + public List getBestImages() { + return bestImages; + } + + public void setBestImages(List bestImages) { + this.bestImages = bestImages; + } } diff --git a/visearch-android/src/test/java/com/visenze/visearch/android/ProductSearchTest.java b/visearch-android/src/test/java/com/visenze/visearch/android/ProductSearchTest.java index 2142c76..0870d23 100644 --- a/visearch-android/src/test/java/com/visenze/visearch/android/ProductSearchTest.java +++ b/visearch-android/src/test/java/com/visenze/visearch/android/ProductSearchTest.java @@ -5,6 +5,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.visenze.visearch.android.model.BestImage; import com.visenze.visearch.android.model.ErrorData; import com.visenze.visearch.android.model.Experiment; import com.visenze.visearch.android.model.ImageResult; @@ -34,7 +35,7 @@ @Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP, manifest = Config.NONE) @RunWith(RobolectricTestRunner.class) public class ProductSearchTest { - ProductSearchService searchService = new ProductSearchService("https://visearch.visenze.com", "123", 456, "visearch-test"); + ProductSearchService searchService = new ProductSearchService("https://search.visenze.com", "123", 456, "visearch-test"); Gson gson = new GsonBuilder() .setLenient() .create(); @@ -691,4 +692,84 @@ public void onSearchResult(ProductResponse response, ErrorData error) { }); } + + @Test + public void testBestImagesResponse() { + String json = + "{\n" + + " \"reqid\": \"01806a667776c6f8a31c28105fd99f\",\n" + + " \"status\": \"OK\",\n" + + " \"method\": \"product/recommendations\",\n" + + " \"page\": 1,\n" + + " \"limit\": 20,\n" + + " \"total\": 200,\n" + + " \"product_types\": [],\n" + + " \"result\": [\n" + + "{\n" + + " \"product_id\": \"dress1\",\n" + + " \"main_image_url\": \"http://test.com/img1.jpg\",\n" + + + " \"best_images\": [\n" + + " {\n" + + " \"type\": \"product\",\n" + + " \"url\": \"url11\",\n" + + " \"index\": \"0\"\n" + + " },\n" + + " {\n" + + " \"type\": \"outfit\",\n" + + " \"url\": \"url21\",\n" + + " \"index\": \"3\"\n" + + " }\n" + + " ],\n" + + + " \"tags\": {\n" + + " \"category\": \"dress\",\n" + + " \"set_id\": \"set1\"\n" + + " },\n" + + " \"score\": 0.9\n" + + " }\n" + + + " ],\n" + + "\"set_info\": [\n" + + " {\n" + + " \"set_id\": \"set1\",\n" + + " \"set_score\": 1000\n" + + " },\n" + + " {\n" + + " \"set_id\": \"set2\",\n" + + " \"set_score\": 900\n" + + " }\n" + + " ]," + + " \"strategy\": {\n" + + " \"id\": 3,\n" + + " \"name\": \"test\",\n" + + " \"algorithm\": \"CTL\"\n" + + " }\n" + + "}"; + + ProductResponse response = gson.fromJson(json, ProductResponse.class); + searchService.handleResponse(response, new ProductSearch.ResultListener() { + @Override + public void onSearchResult(ProductResponse response, ErrorData error) { + assertNull(error); + + List result = response.getProducts(); + assertEquals(1, result.size()); + + List bestImages = result.get(0).getBestImages(); + assertEquals(2, bestImages.size()); + + BestImage b1 = bestImages.get(0); + assertEquals("0", b1.getIndex()); + assertEquals("product", b1.getType()); + assertEquals("url11", b1.getUrl()); + + BestImage b2 = bestImages.get(1); + assertEquals("3", b2.getIndex()); + assertEquals("outfit", b2.getType()); + assertEquals("url21", b2.getUrl()); + } + }); + + } }