1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of gpupo/netshoes-sdk |
5
|
|
|
* Created by Gilmar Pupo <[email protected]> |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
* For more information, see <http://www.g1mr.com/>. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Gpupo\NetshoesSdk\Entity\Product\Sku; |
12
|
|
|
|
13
|
|
|
use Gpupo\CommonSdk\Entity\EntityInterface; |
14
|
|
|
use Gpupo\NetshoesSdk\Entity\ManagerAbstract; |
15
|
|
|
|
16
|
|
|
class Manager extends ManagerAbstract |
17
|
|
|
{ |
18
|
|
|
protected $entity = 'SkuCollection'; |
19
|
|
|
|
20
|
|
|
protected $maps = [ |
21
|
|
|
'save' => ['POST', '/products/{productId}/skus'], //Create a new sku for a product |
22
|
|
|
'findSkuById' => ['GET', '/products/{productId}/skus/{itemId}'], // Get the a sku by product Id and sku Id |
23
|
|
|
'update' => ['PUT', '/products/{productId}/skus/{itemId}'], //Update a product based on SKU |
24
|
|
|
'findById' => ['GET', '/products/{itemId}/skus'], //Get the list of product skus |
25
|
|
|
'saveStatus' => ['PUT', '/skus/{sku}/bus/{buId}/status'], //Enable or disable sku for sale |
26
|
|
|
'savePriceSchedule' => ['POST', '/skus/{sku}/priceSchedules'], //Save a price schedule |
27
|
|
|
'savePrice' => ['PUT', '/skus/{sku}/prices'], //Save a base price |
28
|
|
|
'saveStock' => ['PUT', '/skus/{sku}/stocks'], //Update stock quantity by sku |
29
|
|
|
]; |
30
|
|
|
|
31
|
|
|
public function save(EntityInterface $product, $route = 'save') |
32
|
|
|
{ |
33
|
|
|
return $this->execute($this->factoryMap('save'), $product->toJson()); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* {@inheritdoc} |
38
|
|
|
*/ |
39
|
|
|
public function update(EntityInterface $entity, EntityInterface $existent = null) |
40
|
|
|
{ |
41
|
|
|
parent::update($entity, $existent); |
42
|
|
|
|
43
|
|
|
return $this->execute($this->factoryMap('update', [ |
44
|
|
|
'productId' => $entity->getId(), |
45
|
|
|
'itemId' => $entity->getId(), |
46
|
|
|
]), $entity->toJson()); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|