|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Yandex PHP Library |
|
4
|
|
|
* |
|
5
|
|
|
* @copyright NIX Solutions Ltd. |
|
6
|
|
|
* @link https://github.com/nixsolutions/yandex-php-library |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @namespace |
|
11
|
|
|
*/ |
|
12
|
|
|
namespace Yandex\Market\Content\Clients; |
|
13
|
|
|
|
|
14
|
|
|
use Yandex\Market\Content\ContentClient; |
|
15
|
|
|
use Yandex\Market\Content\Models; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Class PopularClient |
|
19
|
|
|
* |
|
20
|
|
|
* @category Yandex |
|
21
|
|
|
* @package MarketContent |
|
22
|
|
|
* |
|
23
|
|
|
* @author Oleg Scherbakov <[email protected]> |
|
24
|
|
|
* @created 08.01.16 01:19 |
|
25
|
|
|
*/ |
|
26
|
|
View Code Duplication |
class PopularClient extends ContentClient |
|
|
|
|
|
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* Get popular models |
|
30
|
|
|
* |
|
31
|
|
|
* Returns popular models of Yandex.Market service according to params. |
|
32
|
|
|
* |
|
33
|
|
|
* @see https://tech.yandex.ru/market/content-data/doc/dg/reference/popular-docpage/ |
|
34
|
|
|
* |
|
35
|
|
|
* @param array $params |
|
36
|
|
|
* |
|
37
|
|
|
* @return Models\ResponsePopularModelsGet |
|
38
|
|
|
*/ |
|
39
|
1 |
|
public function getModels($params = array()) |
|
40
|
|
|
{ |
|
41
|
1 |
|
$resource = 'popular.json'; |
|
42
|
1 |
|
$resource .= '?' . $this->buildQueryString($params); |
|
43
|
1 |
|
$response = $this->getServiceResponse($resource); |
|
44
|
|
|
|
|
45
|
1 |
|
$getPopularModelsResponse = new Models\ResponsePopularModelsGet($response); |
|
46
|
|
|
|
|
47
|
1 |
|
return $getPopularModelsResponse; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Get popular category models |
|
52
|
|
|
* |
|
53
|
|
|
* Returns popular category models of Yandex.Market service according to params. |
|
54
|
|
|
* |
|
55
|
|
|
* @see https://tech.yandex.ru/market/content-data/doc/dg/reference/popular-category-id-docpage/ |
|
56
|
|
|
* |
|
57
|
|
|
* @param int $categoryId |
|
58
|
|
|
* @param array $params |
|
59
|
|
|
* |
|
60
|
|
|
* @return Models\ResponsePopularCategoryModelsGet |
|
61
|
|
|
*/ |
|
62
|
1 |
|
public function getCategoryModels($categoryId, $params = array()) |
|
63
|
|
|
{ |
|
64
|
1 |
|
$resource = 'popular/' . $categoryId . '.json'; |
|
65
|
1 |
|
$resource .= '?' . $this->buildQueryString($params); |
|
66
|
1 |
|
$response = $this->getServiceResponse($resource); |
|
67
|
|
|
|
|
68
|
1 |
|
$getPopularCategoryModelsResponse = new Models\ResponsePopularCategoryModelsGet($response); |
|
69
|
|
|
|
|
70
|
1 |
|
return $getPopularCategoryModelsResponse; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.