| @@ 324-333 (lines=10) @@ | ||
| 321 | /* |
|
| 322 | * Helper methods |
|
| 323 | */ |
|
| 324 | protected function createDiscount($obj, string $type) : array |
|
| 325 | { |
|
| 326 | Assert::that($type)->choice(self::getTypes()); |
|
| 327 | ||
| 328 | return (array)$this->master->doRequest( |
|
| 329 | 'POST', |
|
| 330 | sprintf('/admin/WEBAPI/Endpoints/v1_0/DiscountService/{KEY}/%s', $type), |
|
| 331 | $obj |
|
| 332 | ); |
|
| 333 | } |
|
| 334 | ||
| 335 | protected function updateDiscount($obj, string $type) : array |
|
| 336 | { |
|
| @@ 335-344 (lines=10) @@ | ||
| 332 | ); |
|
| 333 | } |
|
| 334 | ||
| 335 | protected function updateDiscount($obj, string $type) : array |
|
| 336 | { |
|
| 337 | Assert::that($type)->choice(self::getTypes()); |
|
| 338 | ||
| 339 | return (array)$this->master->doRequest( |
|
| 340 | 'PUT', |
|
| 341 | sprintf('/admin/WEBAPI/Endpoints/v1_0/DiscountService/{KEY}/%s', $type), |
|
| 342 | $obj |
|
| 343 | ); |
|
| 344 | } |
|
| 345 | ||
| 346 | protected function getDiscount(int $id, string $type) : array |
|
| 347 | { |
|
| @@ 346-355 (lines=10) @@ | ||
| 343 | ); |
|
| 344 | } |
|
| 345 | ||
| 346 | protected function getDiscount(int $id, string $type) : array |
|
| 347 | { |
|
| 348 | Assert::that($id)->greaterThan(0, '$id must be positive'); |
|
| 349 | Assert::that($type)->choice(self::getTypes()); |
|
| 350 | ||
| 351 | return (array)$this->master->doRequest( |
|
| 352 | 'GET', |
|
| 353 | sprintf('/admin/WEBAPI/Endpoints/v1_0/DiscountService/{KEY}/%s/%d', $type, $id) |
|
| 354 | ); |
|
| 355 | } |
|
| 356 | ||
| 357 | protected function getDiscounts(int $siteId, int $page, int $pageSize, string $type) : array |
|
| 358 | { |
|