diff --git a/pom.xml b/pom.xml index 856efc2..267c6fa 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ <groupId>com.visenze</groupId> <artifactId>visearch-java-sdk</artifactId> <name>ViSearch Java SDK</name> - <version>1.14.3</version> + <version>1.14.4</version> <packaging>jar</packaging> <url>https://github.com/visenze/visearch-sdk-java</url> <description>ViSearch Java SDK</description> diff --git a/src/main/java/com/visenze/visearch/BrowseLinkedGalleryParams.java b/src/main/java/com/visenze/visearch/BrowseLinkedGalleryParams.java new file mode 100644 index 0000000..3ce338b --- /dev/null +++ b/src/main/java/com/visenze/visearch/BrowseLinkedGalleryParams.java @@ -0,0 +1,29 @@ +package com.visenze.visearch; + +import com.google.common.collect.Multimap; + +/** + * Created by Hung on 8/7/24. + */ +public class BrowseLinkedGalleryParams extends BaseSearchParams<BrowseLinkedGalleryParams> { + private String strategyId; + + public BrowseLinkedGalleryParams(String strategyId) { + this.strategyId = strategyId; + } + + @Override + public Multimap<String, String> toMap() { + Multimap<String, String> map = super.toMap(); + + if (strategyId != null) { + map.put("strategy_id", strategyId.toString()); + } + + return map; + } + + public String getStrategyId() { + return strategyId; + } +} diff --git a/src/main/java/com/visenze/visearch/ViSearch.java b/src/main/java/com/visenze/visearch/ViSearch.java index 41f4f78..41d4991 100644 --- a/src/main/java/com/visenze/visearch/ViSearch.java +++ b/src/main/java/com/visenze/visearch/ViSearch.java @@ -207,6 +207,10 @@ public PagedSearchResult search(SearchParams searchParams) { return searchOperations.search(searchParams); } + @Override + public PagedSearchResult browseLinkedGalleryImages(BrowseLinkedGalleryParams params) { + return searchOperations.browseLinkedGalleryImages(params); + } /** * Search for similar images from the ViSearch App given image and/or text query. diff --git a/src/main/java/com/visenze/visearch/internal/SearchOperations.java b/src/main/java/com/visenze/visearch/internal/SearchOperations.java index 03b3457..3e645c8 100644 --- a/src/main/java/com/visenze/visearch/internal/SearchOperations.java +++ b/src/main/java/com/visenze/visearch/internal/SearchOperations.java @@ -8,6 +8,8 @@ public interface SearchOperations { PagedSearchResult recommendation(RecommendSearchParams searchParams); + PagedSearchResult browseLinkedGalleryImages(BrowseLinkedGalleryParams params); + PagedSearchResult colorSearch(ColorSearchParams colorSearchParams); PagedSearchResult uploadSearch(UploadSearchParams uploadSearchParams); diff --git a/src/main/java/com/visenze/visearch/internal/SearchOperationsImpl.java b/src/main/java/com/visenze/visearch/internal/SearchOperationsImpl.java index 11f9af0..f901f52 100644 --- a/src/main/java/com/visenze/visearch/internal/SearchOperationsImpl.java +++ b/src/main/java/com/visenze/visearch/internal/SearchOperationsImpl.java @@ -28,6 +28,7 @@ public class SearchOperationsImpl extends BaseViSearchOperations implements Sear private static final String ENDPOINT_MULTI_SEARCH_AUTOCOMPLETE = "/multisearch/autocomplete"; private static final String ENDPOINT_SEARCH = "/search"; + private static final String ENDPOINT_BROWSE_LINKED_GALLERY = "/linked/gallery/browse"; private static final String ENDPOINT_RECOMMENDATION = "/recommendations"; private static final String ENDPOINT_COLOR_SEARCH = "/colorsearch"; private static final String ENDPOINT_SIMILAR_PRODUCTS_SEARCH = "/similarproducts"; @@ -48,6 +49,16 @@ public PagedSearchResult search(SearchParams searchParams) { } } + @Override + public PagedSearchResult browseLinkedGalleryImages(BrowseLinkedGalleryParams params) { + try { + ViSearchHttpResponse response = viSearchHttpClient.get(ENDPOINT_BROWSE_LINKED_GALLERY, params.toMap()); + return getPagedResult(response); + } catch (InternalViSearchException e) { + return new PagedSearchResult(e.getMessage(), e.getCause(), e.getServerRawResponse()); + } + } + @Override public PagedSearchResult recommendation(RecommendSearchParams recommendSearchParams) { try { @@ -126,7 +137,7 @@ public PagedSearchResult similarProductsSearch(UploadSearchParams uploadSearchPa /** * Extract feature string (encoded in base 64) given an image file or url. * - * @param uploadSearchParams the upload search parameters, must contain a image file or a url + * @param uploadSearchParams the upload search parameters, must contain an image file or url * @return the feature response string result */ @Override @@ -367,7 +378,7 @@ private PagedSearchResult getPagedResult(ViSearchHttpResponse httpResponse) { result.setSetInfoList(setInfoList); } - // For similarproducts search, try to cover it's result into discoversearch result. + // For similarproducts search, try to convert its result into discoversearch result. JsonNode groupResult = node.get(ViSearchHttpConstants.GROUP_RESULT); if (groupResult != null && groupResult instanceof ArrayNode) { List<ProductType> productTypes = result.getProductTypes();