Skip to content

Commit

Permalink
Merge pull request #104 from visenze/feature/pin_enhacements
Browse files Browse the repository at this point in the history
[API-10051] Update response fields for pin hide enhancements
  • Loading branch information
thehung111 authored Jan 10, 2024
2 parents 98c68c6 + 737f805 commit 24e3040
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>com.visenze</groupId>
<artifactId>visearch-java-sdk</artifactId>
<name>ViSearch Java SDK</name>
<version>1.14.1</version>
<version>1.14.2</version>
<packaging>jar</packaging>
<url>https://github.com/visenze/visearch-sdk-java</url>
<description>ViSearch Java SDK</description>
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/com/visenze/productsearch/ProductSearchResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ public class ProductSearchResponse extends BaseProductSearchResponse {
@JsonProperty("excluded_pids")
private List<String> excludedPids;

@JsonProperty("hidden_categories")
private List<String> hiddenCategories;

@JsonProperty("pin_category_pid_map")
private Map<String, String> pinCategoryPidMap;

@JsonProperty("set_info")
private List<SetInfo> setInfoList;

Expand Down Expand Up @@ -259,6 +265,22 @@ public void setExcludedPids(List<String> excludedPids) {
this.excludedPids = excludedPids;
}

public List<String> getHiddenCategories() {
return hiddenCategories;
}

public void setHiddenCategories(List<String> hiddenCategories) {
this.hiddenCategories = hiddenCategories;
}

public Map<String, String> getPinCategoryPidMap() {
return pinCategoryPidMap;
}

public void setPinCategoryPidMap(Map<String, String> pinCategoryPidMap) {
this.pinCategoryPidMap = pinCategoryPidMap;
}

public List<SetInfo> getSetInfoList() {
return setInfoList;
}
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/com/visenze/visearch/PagedSearchResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public class PagedSearchResult extends PagedResult<ImageResult> {

private List<String> excludedImNames;

private List<String> hiddenCategories;

private Map<String, String> pinCategoryPidMap;

private List<SetInfo> setInfoList;

private String reqId;
Expand Down Expand Up @@ -175,6 +179,22 @@ public void setExcludedImNames(List<String> excludedImNames) {
this.excludedImNames = excludedImNames;
}

public List<String> getHiddenCategories() {
return hiddenCategories;
}

public void setHiddenCategories(List<String> hiddenCategories) {
this.hiddenCategories = hiddenCategories;
}

public Map<String, String> getPinCategoryPidMap() {
return pinCategoryPidMap;
}

public void setPinCategoryPidMap(Map<String, String> pinCategoryPidMap) {
this.pinCategoryPidMap = pinCategoryPidMap;
}

public List<SetInfo> getSetInfoList() {
return setInfoList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,18 @@ private PagedSearchResult getPagedResult(ViSearchHttpResponse httpResponse) {
result.setExcludedImNames(excludedImNames);
}

JsonNode hiddenCategoriesNode = node.get(ViSearchHttpConstants.HIDDEN_CATEGORIES);
if (hiddenCategoriesNode != null) {
List<String> hiddenCategories = deserializeListResult(response, hiddenCategoriesNode, String.class);
result.setHiddenCategories(hiddenCategories);
}

JsonNode pinCategoryPidMapNode = node.get(ViSearchHttpConstants.PIN_CATEGORY_PID_MAP);
if (pinCategoryPidMapNode != null) {
Map<String, String> pinCategoryPidMap = deserializeMapResult(response, pinCategoryPidMapNode, String.class, String.class);
result.setPinCategoryPidMap(pinCategoryPidMap);
}

JsonNode setInfoListNode = node.get(ViSearchHttpConstants.SET_INFO);
if (setInfoListNode != null) {
List<SetInfo> setInfoList = deserializeListResult(response, setInfoListNode, SetInfo.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ public abstract class ViSearchHttpConstants {
public static final String SHOW_EXCLUDED_PIDS = "show_excluded_pids";
public static final String SHOW_PINNED_PIDS = "show_pinned_pids";
public static final String EXCLUDED_IM_NAMES = "excluded_im_names";
public static final String HIDDEN_CATEGORIES = "hidden_categories";

public static final String PIN_CATEGORY_PID_MAP = "pin_category_pid_map";

public static final String USE_SET_BASED_CTL = "use_set_based_ctl";
public static final String SET_LIMIT = "set_limit";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,11 @@ public void testRecommendationResponsePinExcludedParsing() {
" }\n" +
" ],\n" +
" \"excluded_im_names\" : [\"im1\", \"im2\"],\n" +
" \"hidden_categories\" : [\"top\", \"shoe\"],\n" +
" \"pin_category_pid_map\": {\n" +
" \"top\": \"top1\",\n" +
" \"shoe\": \"shoe2\"\n" +
" },\n" +
" \"reqid\": \"1317439821672620035\"\n" +
"}";
when(response.getBody()).thenReturn(responseBody);
Expand Down Expand Up @@ -1396,6 +1401,14 @@ public void testRecommendationResponsePinExcludedParsing() {
assertEquals("im1" , result.getExcludedImNames().get(0));
assertEquals("im2" , result.getExcludedImNames().get(1));

assertEquals(2, result.getHiddenCategories().size());
assertEquals("top" , result.getHiddenCategories().get(0));
assertEquals("shoe" , result.getHiddenCategories().get(1));

assertEquals(2, result.getPinCategoryPidMap().size());
assertEquals("top1", result.getPinCategoryPidMap().get("top"));
assertEquals("shoe2", result.getPinCategoryPidMap().get("shoe"));

}


Expand Down

0 comments on commit 24e3040

Please sign in to comment.