Skip to content

Commit 5bcdb2b

Browse files
Merge branch '2.3-develop' into source-type-pool
2 parents 8c3efd4 + a8e666a commit 5bcdb2b

10 files changed

+727
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\ImportService\Api\Data;
9+
10+
/**
11+
* Class ImportStatusResponse
12+
*/
13+
interface ImportStatusResponseInterface
14+
{
15+
const STATUS_PROCESSING = 'processing';
16+
const STATUS_COMPLETED = 'completed';
17+
const STATUS_FAILED = 'failed';
18+
19+
const STATUS = 'status';
20+
const ERROR = 'error';
21+
const UUID = 'uuid';
22+
const ENTITY_TYPE = 'entity_type';
23+
const USER_ID = 'user_id';
24+
const USER_TYPE = 'user_type';
25+
const ITEMS = 'items';
26+
27+
/**
28+
* Get status
29+
*
30+
* @return string
31+
*/
32+
public function getStatus();
33+
34+
/**
35+
* Get error if there is any with import process
36+
*
37+
* @return string|null
38+
*/
39+
public function getError();
40+
41+
/**
42+
* Get uuid
43+
*
44+
* @return int
45+
*/
46+
public function getUuid();
47+
48+
/**
49+
* Get imported entity type
50+
*
51+
* @return string
52+
*/
53+
public function getEntityType();
54+
55+
/**
56+
* Retrieve current user ID
57+
*
58+
* @return int
59+
*/
60+
public function getUserId();
61+
62+
/**
63+
* Retrieve current user type
64+
*
65+
* @return int
66+
*/
67+
public function getUserType();
68+
69+
/**
70+
* Get import items status
71+
*
72+
* @return \Magento\ImportService\Api\Data\ImportStatusResponseItemInterface[]
73+
*/
74+
public function getItems();
75+
76+
/**
77+
* Set import process status
78+
*
79+
* @param string $status
80+
* @return \Magento\ImportService\Api\Data\ImportStatusResponseInterface
81+
*/
82+
public function setStatus($status);
83+
84+
/**
85+
* Set import process error if there is any
86+
*
87+
* @param string $error
88+
* @return \Magento\ImportService\Api\Data\ImportStatusResponseInterface
89+
*/
90+
public function setError($error);
91+
92+
/**
93+
* Set uuid
94+
*
95+
* @param int $uuid
96+
* @return \Magento\ImportService\Api\Data\ImportStatusResponseInterface
97+
*/
98+
public function setUuid($uuid);
99+
100+
/**
101+
* Set imported entity type
102+
*
103+
* @param string $entityType
104+
* @return \Magento\ImportService\Api\Data\ImportStatusResponseInterface
105+
*/
106+
public function setEntityType($entityType);
107+
108+
/**
109+
* Set user id
110+
*
111+
* @param int $userId
112+
* @return \Magento\ImportService\Api\Data\ImportStatusResponseInterface
113+
*/
114+
public function setUserId($userId);
115+
116+
/**
117+
* Set user type
118+
*
119+
* @param int $userType
120+
* @return \Magento\ImportService\Api\Data\ImportStatusResponseInterface
121+
*/
122+
public function setUserType($userType);
123+
124+
/**
125+
* Set imported items
126+
*
127+
* @param \Magento\ImportService\Api\Data\ImportStatusResponseItemInterface[] $items
128+
* @return \Magento\ImportService\Api\Data\ImportStatusResponseInterface
129+
*/
130+
public function setItems($items);
131+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\ImportService\Api\Data;
9+
10+
/**
11+
* Class ImportStatusResponseItem
12+
*/
13+
interface ImportStatusResponseItemInterface
14+
{
15+
const UUID = 'uuid';
16+
const STATUS = 'status';
17+
const SERIALIZED_DATA = 'serialized_data';
18+
const RESULT_SERIALIZED_DATA = 'result_serialized_data';
19+
const ERROR_CODE = 'error_code';
20+
const RESULT_MESSAGE = 'result_message';
21+
22+
/**
23+
* Get uuid
24+
*
25+
* @return int
26+
*/
27+
public function getUuid();
28+
29+
/**
30+
* Get status
31+
*
32+
* @return string
33+
*/
34+
public function getStatus();
35+
36+
/**
37+
* Get serialized data
38+
*
39+
* @return string
40+
*/
41+
public function getSerializedData();
42+
43+
/**
44+
* Get serialized data result
45+
*
46+
* @return string
47+
*/
48+
public function getResultSerializedData();
49+
50+
/**
51+
* Get error code
52+
*
53+
* @return string|null
54+
*/
55+
public function getErrorCode();
56+
57+
/**
58+
* Get result message
59+
*
60+
* @return string
61+
*/
62+
public function getResultMessage();
63+
64+
/**
65+
* Set uuid
66+
*
67+
* @param int $uuid
68+
* @return \Magento\ImportService\Api\Data\ImportStatusResponseItemInterface
69+
*/
70+
public function setUuid($uuid);
71+
72+
/**
73+
* Set imported status
74+
*
75+
* @param string $status
76+
* @return \Magento\ImportService\Api\Data\ImportStatusResponseItemInterface
77+
*/
78+
public function setStatus($status);
79+
80+
/**
81+
* Set serialized data
82+
*
83+
* @param string $serializedData
84+
* @return \Magento\ImportService\Api\Data\ImportStatusResponseItemInterface
85+
*/
86+
public function setSerializedData($serializedData);
87+
88+
/**
89+
* Set serialized result data
90+
*
91+
* @param string $resultSerializedData
92+
* @return \Magento\ImportService\Api\Data\ImportStatusResponseItemInterface
93+
*/
94+
public function setResultSerializedData($resultSerializedData);
95+
96+
/**
97+
* Set error code if occured
98+
*
99+
* @param string $errorCode
100+
* @return \Magento\ImportService\Api\Data\ImportStatusResponseItemInterface
101+
*/
102+
public function setErrorCode($errorCode);
103+
104+
/**
105+
* Set result message for process
106+
*
107+
* @param string $resultMessage
108+
* @return \Magento\ImportService\Api\Data\ImportStatusResponseItemInterface
109+
*/
110+
public function setResultMessage($resultMessage);
111+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\ImportService\Api;
9+
10+
/**
11+
* Class ImportStatus
12+
*/
13+
interface ImportStatusInterface
14+
{
15+
/**
16+
* Get import source status.
17+
*
18+
* @param int $uuid
19+
* @return \Magento\ImportService\Api\Data\ImportStatusResponseInterface
20+
*/
21+
public function execute(int $uuid);
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\ImportService\Model;
9+
10+
use Magento\ImportService\Api\ImportStatusInterface;
11+
use Magento\ImportService\Api\Data\ImportStatusResponseInterface;
12+
use Magento\ImportService\Model\ImportStatusResponseItemFactory;
13+
14+
/**
15+
* Class Import
16+
*
17+
* @package Magento\ImportService\Model
18+
*/
19+
class ImportStatus implements ImportStatusInterface
20+
{
21+
/**
22+
* Import response factory instance
23+
*
24+
* @var ImportStatusResponse
25+
*/
26+
private $responseFactory;
27+
28+
/**
29+
* Import response item factory instance
30+
*
31+
* @var ImportStatusResponseItem
32+
*/
33+
private $responseItemFactory;
34+
35+
/**
36+
* Status constructor.
37+
*
38+
* @param ImportStatusResponseFactory $responseFactory
39+
* @param ImportStatusResponseItemFactory $responseItemFactory
40+
*/
41+
public function __construct(
42+
ImportStatusResponseFactory $responseFactory,
43+
ImportStatusResponseItemFactory $responseItemFactory
44+
) {
45+
$this->responseFactory = $responseFactory;
46+
$this->responseItemFactory = $responseItemFactory;
47+
}
48+
49+
/**
50+
* Get import source status.
51+
*
52+
* @param int $uuid
53+
* @return ImportStatusResponseFactory
54+
*/
55+
public function execute(int $uuid)
56+
{
57+
// Create new response object
58+
$response = $this->responseFactory->create();
59+
60+
try
61+
{
62+
// Set the required response parameters with appropriate details
63+
$response->setStatus(ImportStatusResponseInterface::STATUS_COMPLETED)
64+
->setUuid($uuid)
65+
->setEntityType('catalog_product')
66+
->setUserId(null)
67+
->setUserType(null);
68+
69+
// Create sample response item object
70+
$item = $this->responseItemFactory->create();
71+
$item->setUuid($uuid)
72+
->setStatus("")
73+
->setSerializedData("")
74+
->setResultSerializedData("")
75+
->setErrorCode("")
76+
->setResultMessage("");
77+
78+
// Set sample response items as an array
79+
$response->setItems([$item]);
80+
} catch (\Exception $e) {
81+
$response = $this->responseFactory->createFailure($e->getMessage());
82+
}
83+
84+
return $response;
85+
}
86+
}

0 commit comments

Comments
 (0)