/** * Sends off a reiview query for the given product Id. It sorts the results by rating from highest * to lowest. * * @param prodId the product id * @param listener the response listener */ public static void runReviewQuery(String prodId, OnBazaarResponse listener) { BazaarRequest request = new BazaarRequest(API_URL, API_KEY, API_VERSION); DisplayParams params = new DisplayParams(); params.addFilter("ProductId", Equality.EQUAL, prodId); params.setLimit(10); // false => descending order params.addSort("Rating", false); OnBazaarResponse response = listener; request.sendDisplayRequest(RequestType.REVIEWS, params, response); }
/** * Sends off a product query with the search term provided. * * @param searchPhrase the search term(s) * @param listener the response listener */ public static void runProductSearchQuery(String searchPhrase, OnBazaarResponse listener) { BazaarRequest request = new BazaarRequest(API_URL, API_KEY, API_VERSION); DisplayParams params = new DisplayParams(); if (!"".equals(searchPhrase.trim())) { // Add search terms to params String[] tokens = searchPhrase.split("\\s+"); for (String term : tokens) { params.setSearch(term); } } params.addStats(IncludeStatsType.REVIEWS); request.sendDisplayRequest(RequestType.PRODUCTS, params, listener); }