/** * Configure Unbxd Client. This method should be called while initializing you application. * If you don't know the configuration details please get in touch with support@unbxd.com * * @param siteKey The Unique Identifier for Site created on Unbxd Platform * @param apiKey API key for calling read APIs * @param secretKey API key for calling Feed APIs */ public static function configure($siteKey, $apiKey, $secretKey = FALSE) { self::$siteKey = $siteKey; self::$apiKey = $apiKey; self::$secretKey = $secretKey; self::$_configured = TRUE; }
public function test_taxonomy_upload() { $response = Unbxd::getFeedClient()->addTaxonomyNode(new TaxonomyNode("1", "Men"))->addTaxonomyNode(new TaxonomyNode("2", "Shoes", array("1")))->addTaxonomyMapping("testsku2", array("1", "2"))->push(FALSE); $this->assertNotNull($response); $this->assertEquals(200, $response->getStatusCode()); $this->assertNotNull($response->getMessage()); $this->assertNotNull($response->getUploadID()); $this->assertEquals(0, count($response->getUnknownSchemaFields())); $this->assertEquals(0, count($response->getFieldErrors())); }
public function test_recommendations() { Unbxd::configure("demosite-u1407617955968", "64a4a2592a648ac8415e13c561e44991", "64a4a2592a648ac8415e13c561e44991"); $client = Unbxd::getRecommendationsClient(); $response = $client->getMoreLikeThis("5315b8555e4016e5737bda03", "uid-1439879404487-19447", "100.0.0.1")->execute(); $this->assertNotNull($response); $this->assertEquals(200, $response->getStatusCode()); $this->assertEquals("OK", $response->getMessage()); $this->assertEquals(8, $response->getTotalResultsCount()); $this->assertEquals(8, $response->getResults()->getResultsCount()); }
public function test_autosuggest() { Unbxd::configure("demosite-u1407617955968", "64a4a2592a648ac8415e13c561e44991", "64a4a2592a648ac8415e13c561e44991"); $client = Unbxd::getAutoSuggestClient(); $response = $client->autosuggest("sh")->setInFieldsCount(3)->setKeywordSuggestionsCount(5)->setPopularProductsCount(10)->setTopQueriesCount(4)->execute(); $this->assertNotNull($response); $this->assertEquals(0, $response->getStatusCode()); $this->assertNotEquals(0, $response->getQueryTime()); $this->assertEquals(0, $response->getErrorCode()); $this->assertEquals("OK", $response->getMessage()); $this->assertNotEquals(0, $response->getTotalResultsCount()); }
public function test_bucket() { $queryParams = array(); $queryParams["fl"] = "uniqueId"; $queryParams["stats"] = "price"; $response = Unbxd::getSearchClient()->bucket("*", "category", $queryParams)->addTextFilter("category_fq", array("men"))->addTextFilter("brand_fq", array("abercrombie"))->addRangeFilter("price_fq", "1000", "2000")->addRangeFilter("price_fq", "2000", "3000")->addSort("price", new SortDir(SortDir::ASC))->setPage(0, 10)->execute(); $this->assertNotNull($response); $this->assertEquals(0, $response->getStatusCode()); $this->assertNotEquals(0, $response->getQueryTime()); $this->assertEquals(0, $response->getErrorCode()); $this->assertEquals("OK", $response->getMessage()); $this->assertNotEquals(1, $response->getTotalResultsCount()); $this->assertNull($response->getResults()); $this->assertEquals(1, $response->getBuckets()->getNumberOfBuckets()); $bucket = $response->getBuckets()->getBuckets(); $this->assertNotEquals(0, $bucket[0]->getTotalResultsCount()); $this->assertEquals(1, count($bucket[0]->getResults()->getAt(0)->getAttributes())); $attr = $bucket[0]->getResults()->getAt(0)->getAttributes(); $this->assertNotNull($attr["uniqueId"]); $this->assertNotNull($response->getStats()); $this->assertNotNull($response->getStats()->getStat("price")->getMin()); $this->assertGreaterThanOrEqual(1000, $response->getStats()->getStat("price")->getmin()); $this->assertLessThanOrEqual(3000, $response->getStats()->getStat("price")->getmax()); }