diff --git a/Generator/Program.cs b/Generator/Program.cs index 9596631d..a4df2745 100644 --- a/Generator/Program.cs +++ b/Generator/Program.cs @@ -42,6 +42,7 @@ phpClientWriter.GenerateClientClass(typeof(Searcher), new[] { "Search", "Predict", "Batch" }); phpClientWriter.GenerateClientClass(typeof(Recommender), new[] { "Recommend" }); phpClientWriter.GenerateClientClass(typeof(SearchAdministrator), new[] { "Delete", "Save", "Load" }); +phpClientWriter.GenerateClientClass(typeof(Analyzer), new[] { "Analyze" }); if (phpWriter.MissingTypeDefinitions.Count > 0) { diff --git a/src/Analyzer.php b/src/Analyzer.php new file mode 100644 index 00000000..b2baadae --- /dev/null +++ b/src/Analyzer.php @@ -0,0 +1,24 @@ +requestAndValidate("ProductPerformanceRequest", $request); + if ($response == Null) + { + return Null; + } + return ProductPerformanceResponse::hydrate($response); + } +} diff --git a/tests/php/integration/ProductPerformanceTest.php b/tests/php/integration/ProductPerformanceTest.php new file mode 100644 index 00000000..db1fee8d --- /dev/null +++ b/tests/php/integration/ProductPerformanceTest.php @@ -0,0 +1,40 @@ +DATASET_ID(), $this->API_KEY()); + + $request = ProductPerformanceRequest::create( + language: null, + currency: null, + byVariant: false, + numberOfResultsPerRequest: 10, + skipNumberOfResults: 0 + )->setOrderBy(ProductPerformanceRequestOrderByOptions::RankBySales) + ->setFromUnixTimeSeconds(time() - 60 * 60 * 24 * 30) + ->setToUnixTimeSeconds(time()) + ->addToClassifications(stringstringKeyValuePair::create("Country", "DK")); + + $response = $analyzer->productPerformance($request); + + self::assertNotNull($response); + /** @var ProductPerformanceResult $first */ + $first = $response->results[0]; + /** @var ProductPerformanceResult $second */ + $fifth = $response->results[4]; // This might be flaky. It is just to check that some element lower down has a smaller number of orders. + + self::assertTrue($first->classifications[0]->sales->orders > $fifth->classifications[0]->sales->orders); + } +} \ No newline at end of file