Completed
Push — master ( 7475e6...f11209 )
by Gilmar
22:09
created

Manager::commit()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
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
namespace Gpupo\NetshoesSdk\Entity\Product;
11
12
use Gpupo\CommonSdk\Entity\EntityInterface;
13
use Gpupo\CommonSdk\Traits\PoolTrait;
14
use Gpupo\NetshoesSdk\Entity\ManagerAbstract;
15
16
class Manager extends ManagerAbstract
17
{
18
    use PoolTrait;
19
20
    protected $entity = 'Product';
21
22
    protected $maps = [
23
        'save'     => ['POST', '/products'],
24
        'findById' => ['GET', '/products/{itemId}'],
25
        'patch'    => ['PATCH', '/products/{itemId}'],
26
        'update'   => ['PUT', '/products/{itemId}'],
27
        'fetch'    => ['GET', '/products?page={offset}&size={limit}'],
28
    ];
29
30
    public function save(EntityInterface $product, $route = 'save')
31
    {
32
        return $this->execute($this->factoryMap('save'), $product->toJson());
33
    }
34
35
    protected function getMap($route, Product $product)
36
    {
37
        return $this->factoryMap($route, ['itemId' => $product->getId()]);
38
    }
39
40
}
41