Completed
Push — master ( a95aa1...ff0f8a )
by Gilmar
100:26 queued 75:25
created

Manager   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 2
c 4
b 0
f 0
lcom 1
cbo 2
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A save() 0 4 1
A update() 0 9 1
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