1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of gpupo/netshoes-sdk |
5
|
|
|
* Created by Gilmar Pupo <[email protected]> |
6
|
|
|
* For the information of copyright and license you should read the file |
7
|
|
|
* LICENSE which is distributed with this source code. |
8
|
|
|
* Para a informação dos direitos autorais e de licença você deve ler o arquivo |
9
|
|
|
* LICENSE que é distribuído com este código-fonte. |
10
|
|
|
* Para obtener la información de los derechos de autor y la licencia debe leer |
11
|
|
|
* el archivo LICENSE que se distribuye con el código fuente. |
12
|
|
|
* For more information, see <http://www.g1mr.com/>. |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace Gpupo\NetshoesSdk\Entity\Product; |
16
|
|
|
|
17
|
|
|
use Gpupo\CommonSdk\Entity\EntityAbstract; |
18
|
|
|
use Gpupo\CommonSdk\Entity\EntityInterface; |
19
|
|
|
use Gpupo\CommonSdk\Exception\RuntimeException; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
*/ |
23
|
|
|
final class Status extends EntityAbstract implements EntityInterface |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @codeCoverageIgnore |
27
|
|
|
*/ |
28
|
|
|
public function getSchema() |
29
|
|
|
{ |
30
|
|
|
return [ |
31
|
|
|
'active' => 'boolean', |
32
|
|
|
'skuSynchronized' => 'boolean', |
33
|
|
|
'statusMatch' => 'string', |
34
|
|
|
'hasPrice' => 'boolean', |
35
|
|
|
'hasStock' => 'boolean', |
36
|
|
|
]; |
37
|
|
|
} |
38
|
|
|
|
39
|
1 |
|
public function getMessage() |
40
|
|
|
{ |
41
|
1 |
|
$statusMatch = $this->get('statusMatch'); |
42
|
|
|
|
43
|
1 |
|
if (empty($statusMatch)) { |
44
|
|
|
throw new RuntimeException('Product Not Found', 404); |
45
|
|
|
} |
46
|
|
|
|
47
|
1 |
|
return $statusMatch; |
48
|
|
|
} |
49
|
|
|
|
50
|
1 |
|
public function isPending() |
51
|
|
|
{ |
52
|
1 |
|
return 'PROCESSADO_INTEGRACAO_CATALOGO' !== $this->getMessage(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function toLog() |
56
|
|
|
{ |
57
|
|
|
$array = [ |
58
|
|
|
'message' => $this->getMessage(), |
59
|
|
|
]; |
60
|
|
|
|
61
|
|
|
foreach (['getActive', 'getHasPrice', 'getHasStock', 'isPending'] as $k) { |
62
|
|
|
$array[$k] = (true === $this->$k()) ? 'yes' : 'no'; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
return $array; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|