| @@ 126-135 (lines=10) @@ | ||
| 123 | * |
|
| 124 | * @return array|\JMS\Serializer\scalar|object |
|
| 125 | */ |
|
| 126 | public function userShow($user_id) |
|
| 127 | { |
|
| 128 | $response = $this->getGuzzleClient() |
|
| 129 | ->get('/users/' . $user_id, $this->setQuery()); |
|
| 130 | ||
| 131 | return $this->serializer->deserialize( |
|
| 132 | $response->getBody()->getContents(), |
|
| 133 | User::class, |
|
| 134 | 'json' |
|
| 135 | ); |
|
| 136 | } |
|
| 137 | ||
| 138 | /** |
|
| @@ 146-160 (lines=15) @@ | ||
| 143 | * |
|
| 144 | * @return array|\JMS\Serializer\scalar|object |
|
| 145 | */ |
|
| 146 | public function userPackages($user_id, $filters = []) |
|
| 147 | { |
|
| 148 | // TODO: Tests |
|
| 149 | $response = $this->getGuzzleClient() |
|
| 150 | ->get( |
|
| 151 | '/users/' . $user_id . '/classifieds_promotion_packs', |
|
| 152 | $this->setQuery($filters) |
|
| 153 | ); |
|
| 154 | ||
| 155 | return $this->serializer->deserialize( |
|
| 156 | $response->getBody()->getContents(), |
|
| 157 | "array<" . Package::class . ">", |
|
| 158 | 'json' |
|
| 159 | ); |
|
| 160 | } |
|
| 161 | ||
| 162 | /** |
|
| 163 | * User show me resource |
|
| @@ 199-211 (lines=13) @@ | ||
| 196 | * |
|
| 197 | * @return array|\JMS\Serializer\scalar|object |
|
| 198 | */ |
|
| 199 | public function categoryPredict($site_id, $title) |
|
| 200 | { |
|
| 201 | $response = $this->getGuzzleClient() |
|
| 202 | ->get( |
|
| 203 | '/sites/' . $site_id . '/category_predictor/predict', |
|
| 204 | $this->setQuery(['title' => $title]) |
|
| 205 | ); |
|
| 206 | return $this->serializer->deserialize( |
|
| 207 | $response->getBody()->getContents(), |
|
| 208 | CategoryPrediction::class, |
|
| 209 | 'json' |
|
| 210 | ); |
|
| 211 | } |
|
| 212 | ||
| 213 | /** |
|
| 214 | * Item List resource |
|
| @@ 220-230 (lines=11) @@ | ||
| 217 | * |
|
| 218 | * @return array|\JMS\Serializer\scalar|object |
|
| 219 | */ |
|
| 220 | public function itemList($user_id) |
|
| 221 | { |
|
| 222 | $response = $this->getGuzzleClient() |
|
| 223 | ->get('/users/' . $user_id . '/items/search', $this->setQuery()); |
|
| 224 | ||
| 225 | return $this->serializer->deserialize( |
|
| 226 | $response->getBody()->getContents(), |
|
| 227 | ItemList::class, |
|
| 228 | 'json' |
|
| 229 | ); |
|
| 230 | } |
|
| 231 | ||
| 232 | /** |
|
| 233 | * Item Show resource |
|
| @@ 239-249 (lines=11) @@ | ||
| 236 | * |
|
| 237 | * @return array|\JMS\Serializer\scalar|object |
|
| 238 | */ |
|
| 239 | public function itemShow($item_id) |
|
| 240 | { |
|
| 241 | $response = $this->getGuzzleClient() |
|
| 242 | ->get('/items/' . $item_id, $this->setQuery()); |
|
| 243 | ||
| 244 | return $this->serializer->deserialize( |
|
| 245 | $response->getBody()->getContents(), |
|
| 246 | Item::class, |
|
| 247 | 'json' |
|
| 248 | ); |
|
| 249 | } |
|
| 250 | ||
| 251 | /** |
|
| 252 | * Item create resource |
|
| @@ 258-271 (lines=14) @@ | ||
| 255 | * |
|
| 256 | * @return array|\JMS\Serializer\scalar|object |
|
| 257 | */ |
|
| 258 | public function itemCreate(Item $item) |
|
| 259 | { |
|
| 260 | $response = $this->getGuzzleClient() |
|
| 261 | ->post( |
|
| 262 | '/items', |
|
| 263 | array_merge($this->setQuery(), $this->setBody($item)) |
|
| 264 | ); |
|
| 265 | ||
| 266 | return $this->serializer->deserialize( |
|
| 267 | $response->getBody()->getContents(), |
|
| 268 | Item::class, |
|
| 269 | 'json' |
|
| 270 | ); |
|
| 271 | } |
|
| 272 | ||
| 273 | /** |
|
| 274 | * Item create resource |
|
| @@ 280-294 (lines=15) @@ | ||
| 277 | * |
|
| 278 | * @return array|\JMS\Serializer\scalar|object |
|
| 279 | */ |
|
| 280 | public function itemUpdate($item_id, $fields) |
|
| 281 | { |
|
| 282 | // TODO: Tests |
|
| 283 | $response = $this->getGuzzleClient() |
|
| 284 | ->put( |
|
| 285 | '/items/' . $item_id, |
|
| 286 | array_merge($this->setQuery(), $this->setBodyArray($fields)) |
|
| 287 | ); |
|
| 288 | ||
| 289 | return $this->serializer->deserialize( |
|
| 290 | $response->getBody()->getContents(), |
|
| 291 | Item::class, |
|
| 292 | 'json' |
|
| 293 | ); |
|
| 294 | } |
|
| 295 | ||
| 296 | /** |
|
| 297 | * Item delete resource |
|
| @@ 328-345 (lines=18) @@ | ||
| 325 | * |
|
| 326 | * @return array|\JMS\Serializer\scalar|object |
|
| 327 | */ |
|
| 328 | public function itemRelist($item_id, $fields) |
|
| 329 | { |
|
| 330 | // TODO: Tests |
|
| 331 | $response = $this->getGuzzleClient() |
|
| 332 | ->post( |
|
| 333 | '/items/' . $item_id . '/relist', |
|
| 334 | array_merge( |
|
| 335 | $this->setQuery(), |
|
| 336 | $this->setBodyArray($fields) |
|
| 337 | ) |
|
| 338 | ); |
|
| 339 | ||
| 340 | return $this->serializer->deserialize( |
|
| 341 | $response->getBody()->getContents(), |
|
| 342 | Item::class, |
|
| 343 | 'json' |
|
| 344 | ); |
|
| 345 | } |
|
| 346 | ||
| 347 | /** |
|
| 348 | * Item update listing type |
|
| @@ 355-372 (lines=18) @@ | ||
| 352 | * |
|
| 353 | * @return array|\JMS\Serializer\scalar|object |
|
| 354 | */ |
|
| 355 | public function itemUpdateListingType($item_id, $listing_type) |
|
| 356 | { |
|
| 357 | // TODO: Tests |
|
| 358 | $response = $this->getGuzzleClient() |
|
| 359 | ->post( |
|
| 360 | '/items/' . $item_id . '/listing_type', |
|
| 361 | array_merge( |
|
| 362 | $this->setQuery(), |
|
| 363 | $this->setBodyArray(['id' => $listing_type]) |
|
| 364 | ) |
|
| 365 | ); |
|
| 366 | ||
| 367 | return $this->serializer->deserialize( |
|
| 368 | $response->getBody()->getContents(), |
|
| 369 | Item::class, |
|
| 370 | 'json' |
|
| 371 | ); |
|
| 372 | } |
|
| 373 | ||
| 374 | /** |
|
| 375 | * Set query |
|