1 | <?php |
||
17 | class Client |
||
18 | { |
||
19 | // /** |
||
20 | // * @var string |
||
21 | // */ |
||
22 | // const BASE_URL = 'https://circus.shopping.yahooapis.jp/ShoppingWebService/V1/'; |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | const BASE_URL = 'https://test.circus.shopping.yahooapis.jp/ShoppingWebService/V1/'; |
||
28 | |||
29 | /** |
||
30 | * @var HttpClient |
||
31 | */ |
||
32 | private $httpClient; |
||
33 | |||
34 | /** |
||
35 | * @var AbstractApi |
||
36 | */ |
||
37 | private $api; |
||
38 | |||
39 | /** |
||
40 | * @var string |
||
41 | */ |
||
42 | private $accessToken; |
||
43 | |||
44 | /** |
||
45 | * @var string |
||
46 | */ |
||
47 | private $refreshToken; |
||
48 | |||
49 | /** |
||
50 | * @param string $accessToken |
||
51 | * @param string $refreshToken |
||
52 | * @param HttpClient|null $httpClient |
||
53 | */ |
||
54 | public function __construct( |
||
69 | |||
70 | /** |
||
71 | * @param AbstractRequest $request |
||
72 | * @return mixed |
||
73 | * @throws ClientException |
||
74 | * @throws ConnectException |
||
75 | * @throws ServerException |
||
76 | */ |
||
77 | public function execute(AbstractRequest $request): array |
||
98 | |||
99 | /** |
||
100 | * @param AbstractApi $api |
||
101 | */ |
||
102 | private function setApi(AbstractApi $api) |
||
106 | |||
107 | /** |
||
108 | * @param array $options |
||
109 | * @return array |
||
110 | */ |
||
111 | private function setAuthorizationHeader(array $options): array |
||
119 | |||
120 | /** |
||
121 | * @param AbstractRequest $request |
||
122 | * @return array |
||
123 | */ |
||
124 | private function setRequestParams(AbstractRequest $request): array |
||
137 | |||
138 | /** |
||
139 | * @param array $options |
||
140 | * @param AbstractRequest $request |
||
141 | * @return array |
||
142 | */ |
||
143 | private function setRequestParamsForGetRequest(array $options, AbstractRequest $request): array |
||
149 | |||
150 | /** |
||
151 | * @param array $options |
||
152 | * @param AbstractRequest $request |
||
153 | * @return array |
||
154 | */ |
||
155 | private function setRequestParamsForPostRequest(array $options, AbstractRequest $request): array |
||
163 | |||
164 | |||
165 | /** |
||
166 | * @param $options |
||
167 | * @return mixed|ResponseInterface |
||
168 | */ |
||
169 | private function request($options) |
||
177 | |||
178 | /** |
||
179 | * @param ResponseInterface $rawResponse |
||
180 | * @return array |
||
181 | */ |
||
182 | private function decodeResponse(ResponseInterface $rawResponse): array |
||
195 | } |
||
196 |