Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions Api/Data/ProductInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?php
/**
* @package Walkthechat\Walkthechat
*
* @author WalktheChat <info@walkthechat.com>
* @copyright 2021 Walkthechat
*
* @license See LICENSE.txt for license details.
*/

namespace Walkthechat\Walkthechat\Api\Data;

/**
* Interface ProductInterface
*
* @package Walkthechat\Walkthechat\Api\Data
*/
interface ProductInterface
{
/**@#+
* Fields
*/
const ID = 'entity_id';
const PRODUCT_ID = 'product_id';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
const STATUS = 'status';
const MESSAGE = 'message';
/**@#- */

/**@#+
* Statuses
*/
const QUEUE_STATUS = 0;
const COMPLETE_STATUS = 1;
const ERROR_STATUS = 2;
/**@#- */

/**
* Return entity_id
*
* @return int
*/
public function getId();

/**
* Set entity_id
*
* @param int $id
*
* @return \Walkthechat\Walkthechat\Api\Data\ProductInterface
*/
public function setId($id);

/**
* Return product_id
*
* @return int
*/
public function getProductId();

/**
* Set product_id
*
* @param int $id
*
* @return \Walkthechat\Walkthechat\Api\Data\ProductInterface
*/
public function setProductId($id);

/**
* Return message
*
* @return string
*/
public function getMessage();

/**
* Set message
*
* @param string $message
*
* @return \Walkthechat\Walkthechat\Api\Data\OrderInterface
*/
public function setMessage($message);

/**
* Return created_at
*
* @return string
*/
public function getCreatedAt();

/**
* Set created_at
*
* @param string $gsmDate
*
* @return \Walkthechat\Walkthechat\Api\Data\ProductInterface
*/
public function setCreatedAt($gsmDate);

/**
* Return updated_at
*
* @return string
*/
public function getUpdatedAt();

/**
* Set updated_at
*
* @param string $gsmDate
*
* @return \Walkthechat\Walkthechat\Api\Data\ProductInterface
*/
public function setUpdatedAt($gsmDate);

/**
* Return status
*
* @return int
*/
public function getStatus();

/**
* Set status
*
* @param int $status
*
* @return \Walkthechat\Walkthechat\Api\Data\ProductInterface
*/
public function setStatus($status);
}
31 changes: 31 additions & 0 deletions Api/Data/ProductSearchResultsInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* @package Walkthechat\Walkthechat
*
* @author WalktheChat <info@walkthechat.com>
* @copyright 2021 Walkthechat
*
* @license See LICENSE.txt for license details.
*/

namespace Walkthechat\Walkthechat\Api\Data;

/**
* Interface ProductSearchResultsInterface
*
* @package Walkthechat\Walkthechat\Api\Data
*/
interface ProductSearchResultsInterface extends \Magento\Framework\Api\SearchResultsInterface
{
/**
* @return \Walkthechat\Walkthechat\Api\Data\ProductInterface[]
*/
public function getItems();

/**
* @param \Walkthechat\Walkthechat\Api\Data\ProductInterface[] $items
*
* @return void
*/
public function setItems(array $items);
}
76 changes: 76 additions & 0 deletions Api/ProductRepositoryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
/**
* @package Walkthechat\Walkthechat
*
* @author WalktheChat <info@walkthechat.com>
* @copyright 2021 Walkthechat
*
* @license See LICENSE.txt for license details.
*/

namespace Walkthechat\Walkthechat\Api;

/**
* Interface ProductRepositoryInterface
*
* @package Walkthechat\Walkthechat\Api
*/
interface ProductRepositoryInterface
{
/**
* Return entity by ID
*
* @param int $id
*
* @return \Walkthechat\Walkthechat\Api\Data\ProductInterface
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function getById($id);

/**
* Return entity by Product ID
*
* @param int $id
*
* @return \Walkthechat\Walkthechat\Api\Data\ProductInterface
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function getByProductId($id);

/**
* Saves entity
*
* @param \Walkthechat\Walkthechat\Api\Data\ProductInterface $product
*
* @return \Walkthechat\Walkthechat\Api\Data\ProductInterface
*/
public function save(\Walkthechat\Walkthechat\Api\Data\ProductInterface $product);

/**
* Remove entity
*
* @param \Walkthechat\Walkthechat\Api\Data\ProductInterface $product
*
* @return void
*/
public function delete(\Walkthechat\Walkthechat\Api\Data\ProductInterface $product);

/**
* Return list of entities
*
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
*
* @return \Walkthechat\Walkthechat\Api\Data\ProductSearchResultsInterface
*/
public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria);

/**
* Bulk save many entities
*
* @param array $data
*
* @return \Walkthechat\Walkthechat\Api\Data\ProductSearchResultsInterface
* @throws \Magento\Framework\Exception\CouldNotSaveException
*/
public function bulkSave(array $data);
}
54 changes: 54 additions & 0 deletions Model/Config/Source/ProductStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/**
* @package Walkthechat\Walkthechat
* @author WalktheChat <info@walkthechat.com>
* @copyright 2021 Walkthechat
* @license See LICENSE_WALKTHECHAT.txt for license details.
*/

namespace Walkthechat\Walkthechat\Model\Config\Source;

/**
* Class ProductStatus
*
* @package Walkthechat\Walkthechat\Model\Config\Source
*/
class ProductStatus implements \Magento\Framework\Option\ArrayInterface
{
/**
* Options getter
*
* @return array
*/
public function toOptionArray()
{
return [
[
'value' => \Walkthechat\Walkthechat\Api\Data\ProductInterface::QUEUE_STATUS,
'label' => __('In Queue'),
],
[
'value' => \Walkthechat\Walkthechat\Api\Data\OrderInterface::COMPLETE_STATUS,
'label' => __('Synced'),
],
[
'value' => \Walkthechat\Walkthechat\Api\Data\OrderInterface::ERROR_STATUS,
'label' => __('Error'),
],
];
}

/**
* Get options in "key-value" format
*
* @return array
*/
public function toArray()
{
return [
\Walkthechat\Walkthechat\Api\Data\OrderInterface::QUEUE_STATUS => __('In Queue'),
\Walkthechat\Walkthechat\Api\Data\OrderInterface::COMPLETE_STATUS => __('Synced'),
\Walkthechat\Walkthechat\Api\Data\OrderInterface::ERROR_STATUS => __('Error')
];
}
}
Loading