Skip to content

Commit

Permalink
Merge pull request #100 from visenze/feature/sti
Browse files Browse the repository at this point in the history
[API-9235] Support box list and group_by request response
  • Loading branch information
thehung111 authored Apr 26, 2023
2 parents 00b67df + 61e146e commit 1721535
Show file tree
Hide file tree
Showing 13 changed files with 173 additions and 7 deletions.
6 changes: 3 additions & 3 deletions doc/ProductSearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.3.1
> Current stable version: 2.3.2
> Minimum Android SDK Version: API 9, Android 2.3
Expand Down Expand Up @@ -65,12 +65,12 @@ include the dependency in your project using gradle. Please change the version t

```gradle
implementation 'com.github.visenze:visenze-tracking-android:0.2.3'
implementation 'com.github.visenze:visearch-sdk-android:2.3.1'
implementation 'com.github.visenze:visearch-sdk-android:2.3.2'
```

### 1.3 Add User Permissions

Our SDK additionally needs these user permissions to work. Add the following declarations to the `AndroidManifest.xml` file.
Our SDK additionally needs these user permissions to work. Add the following declarations to the `AndroidManifest.xml` file. Note that camera permission is optional.

```xml
<?xml version="1.0" encoding="utf-8"?>
Expand Down
4 changes: 2 additions & 2 deletions doc/ViSearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.3.1
>Current stable version: 2.3.2
>Minimum Android SDK Version: API 9, Android 2.3
Expand Down Expand Up @@ -81,7 +81,7 @@ include the dependency in your project using gradle. Please change the version t

```gradle
implementation 'com.github.visenze:visenze-tracking-android:0.2.3'
implementation 'com.github.visenze:visearch-sdk-android:2.3.1'
implementation 'com.github.visenze:visearch-sdk-android:2.3.2'
```

### 1.3 Add User Permissions
Expand Down
4 changes: 2 additions & 2 deletions visearch-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ plugins {

def versionMajor = 2
def versionMinor = 3
def versionPatch = 1
version = '2.3.1'
def versionPatch = 2
version = '2.3.2'

android {
compileSdkVersion 29
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public class BaseSearchParams {

private String sortBy;

private String strategyId;

/**
* The default sets limit at 10 and page at 1, other basic parameters are set as null
*/
Expand Down Expand Up @@ -171,6 +173,10 @@ public BaseSearchParams setSortBy(String sortBy) {
return this;
}

public BaseSearchParams setStrategyId(String strategyId) {
this.strategyId = strategyId;
return this;
}

/**
* Get the sortBy value
Expand Down Expand Up @@ -317,6 +323,10 @@ public Integer getFacetsLimit() {
return facetsLimit;
}

public String getStrategyId() {
return strategyId;
}

public Map<String, List<String> > toMap() {
Map<String, List<String> > map = new HashMap<String, List<String> >();

Expand Down Expand Up @@ -352,6 +362,10 @@ public Map<String, List<String> > toMap() {
putStringInMap(map, "sort_by", sortBy);
}

if (strategyId != null) {
putStringInMap(map, "strategy_id", strategyId);
}

if (custom != null && custom.size() > 0) {
for (String key : custom.keySet()) {
putStringInMap(map, key, custom.get(key));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class IdSearchParams extends SearchParams {
private Boolean useSetBasedCtl;
private Boolean showBestProductImages;

private List<String> box;

public IdSearchParams() {
super();
}
Expand Down Expand Up @@ -116,6 +118,22 @@ public void setUseSetBasedCtl(Boolean useSetBasedCtl) {
this.useSetBasedCtl = useSetBasedCtl;
}

public Boolean getShowBestProductImages() {
return showBestProductImages;
}

public void setShowBestProductImages(Boolean showBestProductImages) {
this.showBestProductImages = showBestProductImages;
}

public List<String> getBox() {
return box;
}

public void setBox(List<String> box) {
this.box = box;
}

@Override
public Map<String, List<String> > toMap() {
Map<String, List<String> > map = super.toMap();
Expand Down Expand Up @@ -153,6 +171,10 @@ public Map<String, List<String> > toMap() {
putStringInMap(map, "show_best_product_images", showBestProductImages.toString());
}

if (box != null && box.size() > 0) {
map.put("box" , box);
}

return map;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

import java.util.List;

public class ProductSearchByIdParams extends BaseProductSearchParams {

@Expose(deserialize = false, serialize = false)
Expand All @@ -29,6 +31,10 @@ public class ProductSearchByIdParams extends BaseProductSearchParams {
@SerializedName("show_best_product_images")
private Boolean showBestProductImages;

@SerializedName("box")
@Expose(deserialize = false, serialize = false)
private List<String> box;

public String getProductId() {
return productId;
}
Expand Down Expand Up @@ -93,6 +99,14 @@ public void setShowBestProductImages(Boolean showBestProductImages) {
this.showBestProductImages = showBestProductImages;
}

public List<String> getBox() {
return box;
}

public void setBox(List<String> box) {
this.box = box;
}

public ProductSearchByIdParams(String productId) {
this.productId = productId;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.visenze.visearch.android;

import com.visenze.visearch.android.model.Facet;
import com.visenze.visearch.android.model.GroupSearchResult;
import com.visenze.visearch.android.model.ImageResult;
import com.visenze.visearch.android.model.ObjectResult;
import com.visenze.visearch.android.model.ProductType;
Expand Down Expand Up @@ -58,6 +59,8 @@ public class ResultList {

private List<SetInfo> setInfoList;

private List<GroupSearchResult> groupResults;

public ResultList() {
imageResult = new ArrayList<ImageResult>();
queryInfo = new HashMap<String, String>();
Expand Down Expand Up @@ -252,4 +255,12 @@ public List<SetInfo> getSetInfoList() {
public void setSetInfoList(List<SetInfo> setInfoList) {
this.setInfoList = setInfoList;
}

public List<GroupSearchResult> getGroupResults() {
return groupResults;
}

public void setGroupResults(List<GroupSearchResult> groupResults) {
this.groupResults = groupResults;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.visenze.visearch.android.model;

import com.google.gson.annotations.SerializedName;

import java.util.List;

public class GroupProductResult {

@SerializedName("group_by_value")
private String groupByValue;

@SerializedName("result")
private List<Product> products;

public String getGroupByValue() {
return groupByValue;
}

public void setGroupByValue(String groupByValue) {
this.groupByValue = groupByValue;
}

public List<Product> getProducts() {
return products;
}

public void setProducts(List<Product> products) {
this.products = products;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.visenze.visearch.android.model;

import com.google.gson.annotations.SerializedName;

import java.util.List;

public class GroupSearchResult {

@SerializedName("result")
private List<ImageResult> result;

@SerializedName("group_by_value")
private String groupByValue;

public List<ImageResult> getResult() {
return result;
}

public void setResult(List<ImageResult> result) {
this.result = result;
}

public String getGroupByValue() {
return groupByValue;
}

public void setGroupByValue(String groupByValue) {
this.groupByValue = groupByValue;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public class ObjectResult extends ProductType {
@SerializedName("facets")
private List<Facet> facets;

@SerializedName("group_results")
private List<GroupSearchResult> groupResults;

public List<ImageResult> getResult() {
return result;
}
Expand Down Expand Up @@ -81,4 +84,12 @@ public List<Facet> getFacets() {
public void setFacets(List<Facet> facets) {
this.facets = facets;
}

public List<GroupSearchResult> getGroupResults() {
return groupResults;
}

public void setGroupResults(List<GroupSearchResult> groupResults) {
this.groupResults = groupResults;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ public class ProductObject extends ProductType {
@SerializedName("result")
private List<Product> result;

@SerializedName("group_results")
private List<GroupProductResult> groupResults;

@SerializedName("total")
private Integer total;

Expand Down Expand Up @@ -81,4 +84,12 @@ public List<Facet> getFacets() {
public void setFacets(List<Facet> facets) {
this.facets = facets;
}

public List<GroupProductResult> getGroupResults() {
return groupResults;
}

public void setGroupResults(List<GroupProductResult> groupResults) {
this.groupResults = groupResults;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public class ProductResponse {
@SerializedName("result")
private List<Product> products;

@SerializedName("group_results")
private List<GroupProductResult> groupResults;

@SerializedName("objects")
private List<ProductObject> objects;

Expand Down Expand Up @@ -212,4 +215,12 @@ public List<SetInfo> getSetInfoList() {
public void setSetInfoList(List<SetInfo> setInfoList) {
this.setInfoList = setInfoList;
}

public List<GroupProductResult> getGroupResults() {
return groupResults;
}

public void setGroupResults(List<GroupProductResult> groupResults) {
this.groupResults = groupResults;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public class ResponseData {
@SerializedName("result")
private List<ImageResult> results;

@SerializedName("group_results")
private List<GroupSearchResult> groupResults;

@SerializedName("product_types")
private List<ProductType> productTypes;

Expand Down Expand Up @@ -212,6 +215,14 @@ public List<String> getExcludedImNames() {
return excludedImNames;
}

public List<GroupSearchResult> getGroupResults() {
return groupResults;
}

public void setGroupResults(List<GroupSearchResult> groupResults) {
this.groupResults = groupResults;
}

public ResultList getResultList() {
ResultList resultList = new ResultList();
if(error != null && error.length > 0) {
Expand All @@ -238,6 +249,7 @@ public ResultList getResultList() {
resultList.setFacets(facets);
resultList.setExcludedImNames(excludedImNames);
resultList.setSetInfoList(setInfoList);
resultList.setGroupResults(groupResults);

return resultList;
}
Expand Down

0 comments on commit 1721535

Please sign in to comment.