1 | <?php |
||
11 | class Client |
||
12 | { |
||
13 | // /** |
||
14 | // * @var string |
||
15 | // */ |
||
16 | // const BASE_URL = 'https://circus.shopping.yahooapis.jp/ShoppingWebService/V1/'; |
||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | const BASE_URL = 'https://test.circus.shopping.yahooapis.jp/ShoppingWebService/V1/'; |
||
22 | |||
23 | /** |
||
24 | * @var HttpClient |
||
25 | */ |
||
26 | private $httpClient; |
||
27 | |||
28 | /** |
||
29 | * @var AbstractApi |
||
30 | */ |
||
31 | private $api; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | private $accessToken; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | private $refreshToken; |
||
42 | |||
43 | /** |
||
44 | * @param string $accessToken |
||
45 | * @param string $refreshToken |
||
46 | * @param HttpClient|null $httpClient |
||
47 | */ |
||
48 | public function __construct( |
||
64 | |||
65 | /** |
||
66 | * @param AbstractApi $api |
||
67 | */ |
||
68 | public function setApi(AbstractApi $api) |
||
72 | |||
73 | /** |
||
74 | * @param AbstractRequest $request |
||
75 | * @return mixed |
||
76 | */ |
||
77 | public function execute(AbstractRequest $request): array |
||
87 | |||
88 | /** |
||
89 | * @param array $options |
||
90 | * @param AbstractRequest $request |
||
91 | * @return array |
||
92 | */ |
||
93 | private function setRequestParams(array $options, AbstractRequest $request): array |
||
103 | |||
104 | /** |
||
105 | * @param array $options |
||
106 | * @param AbstractRequest $request |
||
107 | * @return array |
||
108 | */ |
||
109 | private function setRequestParamsForGetRequest(array $options, AbstractRequest $request): array |
||
115 | |||
116 | /** |
||
117 | * @param array $options |
||
118 | * @param AbstractRequest $request |
||
119 | * @return array |
||
120 | */ |
||
121 | private function setRequestParamsForPostRequest(array $options, AbstractRequest $request): array |
||
129 | |||
130 | /** |
||
131 | * @param array $options |
||
132 | * @return array |
||
133 | */ |
||
134 | private function setAuthorizationHeader(array $options): array |
||
142 | |||
143 | /** |
||
144 | * @param $options |
||
145 | * @return mixed|ResponseInterface |
||
146 | */ |
||
147 | private function request($options) |
||
155 | |||
156 | /** |
||
157 | * @param ResponseInterface $rawResponse |
||
158 | * @return array |
||
159 | */ |
||
160 | private function decodeResponse(ResponseInterface $rawResponse): array |
||
173 | } |
||
174 |