1 | <?php |
||
20 | abstract class Service implements ServiceInterface |
||
21 | { |
||
22 | use ConfigurableTrait; |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $name; |
||
28 | |||
29 | /** |
||
30 | * @var TransportInterface |
||
31 | */ |
||
32 | protected $transport; |
||
33 | |||
34 | /** |
||
35 | * @var CredentialsInterface |
||
36 | */ |
||
37 | protected $credentials; |
||
38 | |||
39 | /** |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $headers = [ |
||
43 | 'Accept-Language' => RequestInterface::LANGUAGE_RU, |
||
44 | 'Use-Operator-Units' => 'true' |
||
45 | ]; |
||
46 | |||
47 | |||
48 | /** |
||
49 | * @inheritdoc |
||
50 | * @throws ErrorResponseException |
||
51 | * @throws \Exception |
||
52 | */ |
||
53 | 1 | public function request(array $params, array $headers = []) |
|
72 | |||
73 | /** |
||
74 | * @param string $name |
||
75 | * @return $this |
||
76 | */ |
||
77 | 73 | public function setName($name) |
|
82 | |||
83 | /** |
||
84 | * @inheritdoc |
||
85 | */ |
||
86 | public function getName() |
||
90 | |||
91 | /** |
||
92 | * @inheritdoc |
||
93 | */ |
||
94 | public function getCredentials() |
||
98 | |||
99 | /** |
||
100 | * @inheritdoc |
||
101 | */ |
||
102 | public function getTransport() |
||
106 | |||
107 | /* Fluid setters */ |
||
108 | |||
109 | /** |
||
110 | * @param TransportInterface $transport |
||
111 | * @return $this |
||
112 | */ |
||
113 | 74 | public function setTransport($transport) |
|
118 | |||
119 | /** |
||
120 | * @param CredentialsInterface $credentials |
||
121 | * @return $this |
||
122 | */ |
||
123 | 74 | public function setCredentials($credentials) |
|
128 | |||
129 | /** |
||
130 | * @param array $headers |
||
131 | * @return $this |
||
132 | */ |
||
133 | public function setHeaders($headers) |
||
138 | |||
139 | /** |
||
140 | * @param $useOperatorUnits |
||
141 | * @return $this |
||
142 | */ |
||
143 | public function setUseOperatorUnits($useOperatorUnits) |
||
151 | |||
152 | /** |
||
153 | * @param $language |
||
154 | * @return $this |
||
155 | */ |
||
156 | public function setLanguage($language) |
||
161 | |||
162 | /** |
||
163 | * @param ResponseInterface $response |
||
164 | * @return array |
||
165 | * @throws ErrorResponseException |
||
166 | */ |
||
167 | 1 | protected function handleResponse(ResponseInterface $response) |
|
195 | |||
196 | /** |
||
197 | * @param ResponseInterface $response |
||
198 | * @return array|\DOMDocument |
||
199 | * @throws ErrorResponseException |
||
200 | * @throws \Exception |
||
201 | */ |
||
202 | protected function handleReportsResponse(ResponseInterface $response) |
||
230 | } |
||
231 |