|
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 SearchClient |
|
19
|
|
|
* |
|
20
|
|
|
* @category Yandex |
|
21
|
|
|
* @package MarketContent |
|
22
|
|
|
* |
|
23
|
|
|
* @author Oleg Scherbakov <[email protected]> |
|
24
|
|
|
* @created 09.01.16 15:03 |
|
25
|
|
|
*/ |
|
26
|
|
View Code Duplication |
class SearchClient extends ContentClient |
|
|
|
|
|
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* Get models & offers search result |
|
30
|
|
|
* |
|
31
|
|
|
* Returns models and offers of Yandex.Market service search result according to params. |
|
32
|
|
|
* |
|
33
|
|
|
* @see https://tech.yandex.ru/market/content-data/doc/dg/reference/search-docpage/ |
|
34
|
|
|
* |
|
35
|
|
|
* @param array $params |
|
36
|
|
|
* |
|
37
|
|
|
* @return Models\ResponseSearchGet |
|
38
|
|
|
*/ |
|
39
|
1 |
|
public function get($params = array()) |
|
40
|
|
|
{ |
|
41
|
1 |
|
$resource = 'search.json'; |
|
42
|
1 |
|
$resource .= '?' . $this->buildQueryString($params); |
|
43
|
1 |
|
$response = $this->getServiceResponse($resource); |
|
44
|
|
|
|
|
45
|
1 |
|
$getSearchResponse = new Models\ResponseSearchGet($response); |
|
46
|
|
|
|
|
47
|
1 |
|
return $getSearchResponse; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Get models & offers search by filters result |
|
52
|
|
|
* |
|
53
|
|
|
* Returns models and offers of Yandex.Market service search by filters result according to params. |
|
54
|
|
|
* |
|
55
|
|
|
* @see https://tech.yandex.ru/market/content-data/doc/dg/reference/filter-id-docpage/ |
|
56
|
|
|
* |
|
57
|
|
|
* @param int $categoryId |
|
58
|
|
|
* @param array $params |
|
59
|
|
|
* |
|
60
|
|
|
* @return Models\ResponseFilterCategoryGet |
|
61
|
|
|
*/ |
|
62
|
1 |
|
public function getFilterCategory($categoryId, $params = array()) |
|
63
|
|
|
{ |
|
64
|
1 |
|
$resource = 'filter/' . $categoryId. '.json'; |
|
65
|
1 |
|
$resource .= '?' . $this->buildQueryString($params); |
|
66
|
1 |
|
$response = $this->getServiceResponse($resource); |
|
67
|
|
|
|
|
68
|
1 |
|
$getFilterCategoryResponse = new Models\ResponseFilterCategoryGet($response); |
|
69
|
|
|
|
|
70
|
1 |
|
return $getFilterCategoryResponse; |
|
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.