| 1 | <?php |
||
| 13 | class CatalogService extends BaseService |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var Catalog[] |
||
| 17 | */ |
||
| 18 | protected $entities = []; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param Catalog $catalog |
||
| 22 | */ |
||
| 23 | 4 | public function add(EntityInterface $catalog) |
|
| 24 | { |
||
| 25 | 4 | if ($catalog instanceof Catalog) { |
|
| 26 | 4 | $this->entities[] = $catalog; |
|
| 27 | 4 | } |
|
| 28 | 4 | } |
|
| 29 | |||
| 30 | /** |
||
| 31 | * @param null $id |
||
| 32 | * |
||
| 33 | * @return array|bool |
||
| 34 | */ |
||
| 35 | 1 | public function lists($id = null) |
|
| 36 | { |
||
| 37 | 1 | $link = $this->getLink(); |
|
| 38 | |||
| 39 | 1 | if ($id !== null) { |
|
| 40 | $link .= '?id' . $id; |
||
| 41 | } |
||
| 42 | |||
| 43 | 1 | $this->request->performRequest($link, [], 'application/json', 'GET'); |
|
| 44 | 1 | $this->response = $this->request->getResponse(); |
|
| 45 | |||
| 46 | 1 | return $this->parseResponseToEntities(); |
|
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @param $array |
||
| 51 | * |
||
| 52 | * @return Catalog |
||
| 53 | */ |
||
| 54 | 4 | public function parseArrayToEntity($array) |
|
| 61 | |||
| 62 | /** |
||
| 63 | * @return string |
||
| 64 | */ |
||
| 65 | 4 | protected function getLink() |
|
| 69 | |||
| 70 | } |