Skip to content

Commit

Permalink
Resolve issues on file name prefix from Source to Import
Browse files Browse the repository at this point in the history
  • Loading branch information
hitarthpattani committed Mar 5, 2019
1 parent 7237f70 commit 206e824
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
namespace Magento\ImportService\Api\Data;

/**
* Class SourceStatusResponse
* Class ImportStatusResponse
*/
interface SourceStatusResponseInterface
interface ImportStatusResponseInterface
{
const STATUS_PROCESSING = 'processing';
const STATUS_COMPLETED = 'completed';
Expand All @@ -27,7 +27,7 @@ interface SourceStatusResponseInterface
/**
* Get status
*
* @return string|null
* @return string
*/
public function getStatus();

Expand All @@ -41,83 +41,77 @@ public function getError();
/**
* Get uuid
*
* @return int|null
* @return int
*/
public function getUuid();

/**
* Get entity type
*
* @return string|null
* @return string
*/
public function getEntityType();

/**
* Retrieve current user ID
*
* @return int|null
* @return int
*/
public function getUserId();

/**
* Retrieve current user type
*
* @return int|null
* @return int
*/
public function getUserType();

/**
* Get import items status
*
* @return \Magento\ImportService\Api\Data\SourceStatusResponseItemInterface[]|null
* @return \Magento\ImportService\Api\Data\ImportStatusResponseItemInterface[]
*/
public function getItems();

/**
* @param $status
* @return \Magento\ImportService\Api\Data\SourceStatusResponseInterface
* @param string $status
* @return \Magento\ImportService\Api\Data\ImportStatusResponseInterface
*/
public function setStatus($status);

/**
* @param $error
* @return \Magento\ImportService\Api\Data\SourceStatusResponseInterface
* @param string $error
* @return \Magento\ImportService\Api\Data\ImportStatusResponseInterface
*/
public function setError($error);

/**
* @param $uuid
* @return \Magento\ImportService\Api\Data\SourceStatusResponseInterface
* @param int $uuid
* @return \Magento\ImportService\Api\Data\ImportStatusResponseInterface
*/
public function setUuid($uuid);

/**
* @param $entityType
* @return \Magento\ImportService\Api\Data\SourceStatusResponseInterface
* @param string $entityType
* @return \Magento\ImportService\Api\Data\ImportStatusResponseInterface
*/
public function setEntityType($entityType);

/**
* @param $userId
* @return \Magento\ImportService\Api\Data\SourceStatusResponseInterface
* @param int $userId
* @return \Magento\ImportService\Api\Data\ImportStatusResponseInterface
*/
public function setUserId($userId);

/**
* @param $userType
* @return \Magento\ImportService\Api\Data\SourceStatusResponseInterface
* @param int $userType
* @return \Magento\ImportService\Api\Data\ImportStatusResponseInterface
*/
public function setUserType($userType);

/**
* @param $items
* @return \Magento\ImportService\Api\Data\SourceStatusResponseInterface
* @param \Magento\ImportService\Api\Data\ImportStatusResponseItemInterface[] $items
* @return \Magento\ImportService\Api\Data\ImportStatusResponseInterface
*/
public function setItems($items);

/**
* @param $item
* @return \Magento\ImportService\Api\Data\SourceStatusResponseInterface
*/
public function addItem($item);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
namespace Magento\ImportService\Api\Data;

/**
* Class SourceStatusResponseItem
* Class ImportStatusResponseItem
*/
interface SourceStatusResponseItemInterface
interface ImportStatusResponseItemInterface
{
const UUID = 'uuid';
const STATUS = 'status';
Expand Down Expand Up @@ -63,37 +63,37 @@ public function getResultMessage();

/**
* @param $uuid
* @return \Magento\ImportService\Api\Data\SourceStatusResponseItemInterface
* @return \Magento\ImportService\Api\Data\ImportStatusResponseItemInterface
*/
public function setUuid($uuid);

/**
* @param $status
* @return \Magento\ImportService\Api\Data\SourceStatusResponseItemInterface
* @return \Magento\ImportService\Api\Data\ImportStatusResponseItemInterface
*/
public function setStatus($status);

/**
* @param $serializedData
* @return \Magento\ImportService\Api\Data\SourceStatusResponseItemInterface
* @return \Magento\ImportService\Api\Data\ImportStatusResponseItemInterface
*/
public function setSerializedData($serializedData);

/**
* @param $resultSerializedData
* @return \Magento\ImportService\Api\Data\SourceStatusResponseItemInterface
* @return \Magento\ImportService\Api\Data\ImportStatusResponseItemInterface
*/
public function setResultSerializedData($resultSerializedData);

/**
* @param $errorCode
* @return \Magento\ImportService\Api\Data\SourceStatusResponseItemInterface
* @return \Magento\ImportService\Api\Data\ImportStatusResponseItemInterface
*/
public function setErrorCode($errorCode);

/**
* @param $resultMessage
* @return \Magento\ImportService\Api\Data\SourceStatusResponseItemInterface
* @return \Magento\ImportService\Api\Data\ImportStatusResponseItemInterface
*/
public function setResultMessage($resultMessage);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
namespace Magento\ImportService\Api;

/**
* Class SourceStatus
* Class ImportStatus
*/
interface SourceStatusInterface
interface ImportStatusInterface
{
/**
* Get source status.
*
* @param string $uuid
* @return \Magento\ImportService\Api\Data\SourceStatusResponseInterface
* @return \Magento\ImportService\Api\Data\ImportStatusResponseInterface
*/
public function execute(string $uuid);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,43 @@

namespace Magento\ImportService\Model;

use Magento\ImportService\Api\SourceStatusInterface;
use Magento\ImportService\Api\Data\SourceStatusResponseInterface;
use Magento\ImportService\Model\SourceStatusResponseItemFactory;
use Magento\Authorization\Model\UserContextInterface;
use Magento\Catalog\Model\Product;
use Magento\ImportService\Api\ImportStatusInterface;
use Magento\ImportService\Api\Data\ImportStatusResponseInterface;
use Magento\ImportService\Model\ImportStatusResponseItemFactory;

/**
* Class Import
*
* @package Magento\ImportService\Model
*/
class SourceStatus implements SourceStatusInterface
class ImportStatus implements ImportStatusInterface
{
/**
* @var SourceStatusResponse
* @var ImportStatusResponse
*/
private $responseFactory;

/**
* @var SourceStatusResponseItem
* @var ImportStatusResponseItem
*/
private $responseItemFactory;

/**
* @var UserContextInterface
*/
private $userContext;

/**
* Status constructor.
* @param SourceStatusResponseFactory $responseFactory
* @param SourceStatusResponseItemFactory $responseItemFactory
* @param UserContextInterface $userContext
* @param ImportStatusResponseFactory $responseFactory
* @param ImportStatusResponseItemFactory $responseItemFactory
*/
public function __construct(
SourceStatusResponseFactory $responseFactory,
SourceStatusResponseItemFactory $responseItemFactory,
UserContextInterface $userContext
ImportStatusResponseFactory $responseFactory,
ImportStatusResponseItemFactory $responseItemFactory
) {
$this->responseFactory = $responseFactory;
$this->responseItemFactory = $responseItemFactory;
$this->userContext = $userContext;
}

/**
* @param string $uuid
* @return SourceStatusResponseFactory
* @return ImportStatusResponseFactory
*/
public function execute(string $uuid)
{
Expand All @@ -63,11 +53,11 @@ public function execute(string $uuid)
try
{
// Set the required response parameters with appropriate details
$response->setStatus(SourceStatusResponseInterface::STATUS_COMPLETED)
$response->setStatus(ImportStatusResponseInterface::STATUS_COMPLETED)
->setUuid($uuid)
->setEntityType(Product::ENTITY)
->setUserId($this->userContext->getUserId())
->setUserType($this->userContext->getUserType());
->setEntityType('catalog_product')
->setUserId(null)
->setUserType(null);

// Create sample response item object
$item = $this->responseItemFactory->create();
Expand All @@ -78,8 +68,8 @@ public function execute(string $uuid)
->setErrorCode("")
->setResultMessage("");

// Add sample response item object to response
$response->addItem($item);
// Set sample response items as an array
$response->setItems([$item]);
} catch (\Exception $e) {
$response = $this->responseFactory->createFailure($e->getMessage());
}
Expand Down
Loading

0 comments on commit 206e824

Please sign in to comment.