|
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; |
|
16
|
|
|
|
|
17
|
|
|
use Gpupo\CommonSdk\Entity\Metadata\MetadataContainerAbstract; |
|
18
|
|
|
use Gpupo\CommonSdk\Traits\FinderTrait; |
|
19
|
|
|
|
|
20
|
|
|
abstract class AbstractMetadata extends MetadataContainerAbstract |
|
21
|
|
|
{ |
|
22
|
|
|
use FinderTrait; |
|
23
|
|
|
|
|
24
|
5 |
|
protected function cutMetadata($raw) |
|
25
|
|
|
{ |
|
26
|
5 |
|
if (empty($raw) || !is_array($raw)) { |
|
27
|
1 |
|
return [[]]; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
4 |
|
if (array_key_exists('_links', $raw)) { |
|
31
|
1 |
|
foreach ($raw['_links'] as $k => $v) { |
|
32
|
1 |
|
$raw['links'][] = [ |
|
33
|
1 |
|
'rel' => $k, |
|
34
|
1 |
|
'href' => current($v), |
|
35
|
|
|
]; |
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
4 |
|
return $this->dataPiece('links', $raw); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
4 |
|
protected function normalizeMetas($metas) |
|
43
|
|
|
{ |
|
44
|
4 |
|
$data = []; |
|
45
|
|
|
$rm = [ |
|
46
|
4 |
|
'http://sandbox-catalogo-vs.netshoes.local/mp-catalogo-api/rs', |
|
47
|
|
|
'http://api-sandbox.netshoes.com.br/api', |
|
48
|
|
|
]; |
|
49
|
|
|
|
|
50
|
4 |
|
if (is_array($metas)) { |
|
51
|
4 |
|
foreach ($metas as $meta) { |
|
52
|
4 |
|
if (array_key_exists('rel', $meta)) { |
|
53
|
4 |
|
$data[$meta['rel']] = str_replace($rm, '', $meta['href']); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
4 |
|
return $data; |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|