-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
316 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace belenka\ExponeaApi\Catalog\Partials; | ||
|
||
use JsonSerializable; | ||
use belenka\ExponeaApi\Interfaces\CreateCatalogInterface; | ||
|
||
/** | ||
* Representation of create catalog object | ||
* @package belenka\ExponeaApi\Catalog\Partials | ||
*/ | ||
class CreateCatalog implements CreateCatalogInterface, JsonSerializable | ||
{ | ||
/** | ||
* @var string|null | ||
*/ | ||
protected $name; | ||
|
||
/** | ||
* @var boolean|null | ||
*/ | ||
protected $isProductCatalog; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $fields = []; | ||
|
||
public function __construct(string $name, $isProductCatalog = false, $fields = []) | ||
{ | ||
$this->setName($name); | ||
$this->setIsProductCatalog($isProductCatalog); | ||
$this->setFields($fields); | ||
} | ||
|
||
public function setName(string $value): void | ||
{ | ||
$this->name = $value; | ||
} | ||
|
||
public function setIsProductCatalog($value): void | ||
{ | ||
$this->isProductCatalog = $value; | ||
} | ||
|
||
public function setFields(array $fields): void | ||
{ | ||
$this->fields = $fields; | ||
} | ||
|
||
public function getName(): int | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function isProductCatalog(): bool | ||
{ | ||
return $this->isProductCatalog; | ||
} | ||
|
||
public function getFields(): array | ||
{ | ||
return $this->fields; | ||
} | ||
|
||
public function jsonSerialize() | ||
{ | ||
return [ | ||
'name' => $this->getName(), | ||
'is_product_catalog' => $this->isProductCatalog(), | ||
'fields' => $this->getFields() | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
namespace belenka\ExponeaApi\Catalog\Response; | ||
|
||
use belenka\ExponeaApi\Exception\Internal\MissingResponseFieldException; | ||
|
||
/** | ||
* Result of getAllCatalogs() call | ||
* @package belenka\ExponeaApi\Response | ||
*/ | ||
class AllCatalogs | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
protected $data; | ||
|
||
/** | ||
* @var boolean | ||
*/ | ||
protected $success; | ||
|
||
const FIELD_DATA = 'data'; | ||
const FIELD_SUCCESS = 'success'; | ||
|
||
/** | ||
* AllCatalog constructor. | ||
* @param array $data | ||
* @throws MissingResponseFieldException | ||
*/ | ||
public function __construct(array $data) | ||
{ | ||
if (isset($data[self::FIELD_DATA])) { | ||
$this->setData($data[self::FIELD_DATA]); | ||
} else { | ||
throw new MissingResponseFieldException(self::FIELD_DATA); | ||
} | ||
|
||
if (isset($data[self::FIELD_SUCCESS])) { | ||
$this->setSuccess($data[self::FIELD_SUCCESS]); | ||
} else { | ||
throw new MissingResponseFieldException(self::FIELD_SUCCESS); | ||
} | ||
} | ||
|
||
/** | ||
* @param array $value | ||
*/ | ||
public function setData(array $value): void | ||
{ | ||
$this->data = $value; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getData(): array | ||
{ | ||
return $this->data; | ||
} | ||
|
||
/** | ||
* @param boolean $value | ||
*/ | ||
public function setSuccess(string $value): void | ||
{ | ||
$this->success = $value; | ||
} | ||
|
||
/** | ||
* @return boolean | ||
*/ | ||
public function getSuccess(): int | ||
{ | ||
return $this->success; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
namespace belenka\ExponeaApi\Catalog\Response; | ||
|
||
use belenka\ExponeaApi\Exception\Internal\MissingResponseFieldException; | ||
|
||
/** | ||
* Result of createCatalog() call | ||
* @package belenka\ExponeaApi\Response | ||
*/ | ||
class CreateCatalog | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $id; | ||
|
||
/** | ||
* @var boolean | ||
*/ | ||
protected $success; | ||
|
||
const FIELD_ID = 'id'; | ||
const FIELD_SUCCESS = 'success'; | ||
|
||
/** | ||
* CreateCatalog constructor. | ||
* @param array $data | ||
* @throws MissingResponseFieldException | ||
*/ | ||
public function __construct(array $data) | ||
{ | ||
if (isset($data[self::FIELD_ID])) { | ||
$this->setId($data[self::FIELD_ID]); | ||
} else { | ||
throw new MissingResponseFieldException(self::FIELD_ID); | ||
} | ||
|
||
if (isset($data[self::FIELD_SUCCESS])) { | ||
$this->setSuccess($data[self::FIELD_SUCCESS]); | ||
} else { | ||
throw new MissingResponseFieldException(self::FIELD_SUCCESS); | ||
} | ||
} | ||
|
||
/** | ||
* @param string $id | ||
*/ | ||
public function setId(string $id): void | ||
{ | ||
$this->id = $id; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getId(): string | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @param boolean $value | ||
*/ | ||
public function setSuccess(string $value): void | ||
{ | ||
$this->success = $value; | ||
} | ||
|
||
/** | ||
* @return boolean | ||
*/ | ||
public function getSuccess(): int | ||
{ | ||
return $this->success; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace belenka\ExponeaApi\Interfaces; | ||
|
||
/** | ||
* Interface describing create catalog for which action should be made | ||
* @package belenka\ExponeaApi\Interfaces | ||
*/ | ||
interface CreateCatalogInterface | ||
{ | ||
/** | ||
* Get catalog Name | ||
* @return string|null | ||
*/ | ||
public function getName(); | ||
|
||
/** | ||
* Is product catalog | ||
* @return boolean|null | ||
*/ | ||
public function isProductCatalog(); | ||
|
||
/** | ||
* Get catalog fields | ||
* @return array|null | ||
*/ | ||
public function getFields(); | ||
|
||
} |