Completed
Pull Request — master (#139)
by
unknown
04:18
created

ShopClient   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 4
c 2
b 1
f 1
lcom 1
cbo 5
dl 0
loc 91
ccs 23
cts 23
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getMatch() 0 10 1
A get() 0 9 1
A getOutlets() 0 10 1
A getOpinions() 0 10 1
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 ShopClient
19
 *
20
 * @category Yandex
21
 * @package  MarketContent
22
 *
23
 * @author  Oleg Scherbakov <[email protected]>
24
 * @created 08.01.16 04:06
25
 */
26
class ShopClient extends ContentClient
27
{
28
    /**
29
     * Get Shop
30
     *
31
     * Returns shop of Yandex.Market service matched specified params.
32
     *
33
     * @see https://tech.yandex.ru/market/content-data/doc/dg/reference/shops-host-docpage/
34
     *
35
     * @param array $params
36
     *
37
     * @return Models\ResponseShopMatchGet
38
     */
39 1
    public function getMatch($params = array())
40
    {
41 1
        $resource = 'shops.json';
42 1
        $resource .= '?' . $this->buildQueryString($params);
43 1
        $response = $this->getServiceResponse($resource);
44
45 1
        $shops = new Models\ResponseShopMatchGet($response);
46
47 1
        return $shops;
48
    }
49
50
    /**
51
     * Get shop information
52
     *
53
     * Returns shop of Yandex.Market.
54
     *
55
     * @see https://tech.yandex.ru/market/content-data/doc/dg/reference/shop-id-docpage/
56
     *
57
     * @param int $shopId
58
     *
59
     * @return Models\Shop
60
     */
61 1
    public function get($shopId)
62
    {
63 1
        $resource = 'shop/' . $shopId . '.json';
64 1
        $response = $this->getServiceResponse($resource);
65
66 1
        $getShopResponse = new Models\ResponseShopGet($response);
67
68 1
        return $getShopResponse->getShop();
69
    }
70
71
    /**
72
     * Get outlets of shop
73
     *
74
     * Returns outlets of Yandex.Market service shop according to params.
75
     *
76
     * @see https://tech.yandex.ru/market/content-data/doc/dg/reference/shop-id-outlets-docpage/
77
     *
78
     * @param int   $shopId
79
     * @param array $params
80
     *
81
     * @return Models\ResponseShopOutletsGet
82
     */
83 1
    public function getOutlets($shopId, $params = array())
84
    {
85 1
        $resource = 'shop/' . $shopId . '/outlets.json';
86 1
        $resource .= '?' . $this->buildQueryString($params);
87 1
        $response = $this->getServiceResponse($resource);
88
89 1
        $shopOutlets = new Models\ResponseShopOutletsGet($response);
90
91 1
        return $shopOutlets;
92
    }
93
94
    /**
95
     * Get opinions of shop
96
     *
97
     * Returns opinions list of Yandex.Market service shop.
98
     *
99
     * @see https://tech.yandex.ru/market/content-data/doc/dg/reference/shop-id-opinion-docpage/
100
     *
101
     * @param int   $shopId
102
     * @param array $params
103
     *
104
     * @return Models\ResponseShopOpinionsGet
105
     */
106 1
    public function getOpinions($shopId, $params = array())
107
    {
108 1
        $resource = 'shop/' . $shopId . '/opinion.json';
109 1
        $resource .= '?' . $this->buildQueryString($params);
110 1
        $response = $this->getServiceResponse($resource);
111
112 1
        $shopOpinions = new Models\ResponseShopOpinionsGet($response);
113
114 1
        return $shopOpinions;
115
    }
116
}
117