Skip to content

Commit 1bb7016

Browse files
authored
Merge pull request #427 from magento-performance/cabpi-346
CABPI-346, CABPI-348
2 parents 21ac01d + 5ff5557 commit 1bb7016

30 files changed

+1725
-332
lines changed
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\AdminAdobeIms\Api\Data;
10+
11+
use Magento\Framework\Api\ExtensibleDataInterface;
12+
13+
/**
14+
* Declare the ims token data service object
15+
* @api
16+
*/
17+
interface ImsWebapiInterface extends ExtensibleDataInterface
18+
{
19+
/**
20+
* Get ID
21+
*
22+
* @return int|null
23+
*/
24+
public function getId();
25+
26+
/**
27+
* Get admin user ID
28+
*
29+
* @return int|null
30+
*/
31+
public function getAdminUserId(): ?int;
32+
33+
/**
34+
* Set admin user ID
35+
*
36+
* @param int $value
37+
* @return $this
38+
*/
39+
public function setAdminUserId(int $value): ImsWebapiInterface;
40+
41+
/**
42+
* Get access token hash
43+
*
44+
* @return string|null
45+
*/
46+
public function getAccessTokenHash(): ?string;
47+
48+
/**
49+
* Set access token hash
50+
*
51+
* @param string $value
52+
* @return $this
53+
*/
54+
public function setAccessTokenHash(string $value): ImsWebapiInterface;
55+
56+
/**
57+
* Get access token
58+
*
59+
* @return string|null
60+
*/
61+
public function getAccessToken(): ?string;
62+
63+
/**
64+
* Set access token
65+
*
66+
* @param string $value
67+
* @return $this
68+
*/
69+
public function setAccessToken(string $value): ImsWebapiInterface;
70+
71+
/**
72+
* Get creation time
73+
*
74+
* @return string|null
75+
*/
76+
public function getCreatedAt(): ?string;
77+
78+
/**
79+
* Set creation time
80+
*
81+
* @param string $value
82+
* @return $this
83+
*/
84+
public function setCreatedAt(string $value): ImsWebapiInterface;
85+
86+
/**
87+
* Get update time
88+
*
89+
* @return string|null
90+
*/
91+
public function getUpdatedAt(): ?string;
92+
93+
/**
94+
* Set update time
95+
*
96+
* @param string $value
97+
* @return $this
98+
*/
99+
public function setUpdatedAt(string $value): ImsWebapiInterface;
100+
101+
/**
102+
* Get last check time
103+
*
104+
* @return string|null
105+
*/
106+
public function getLastCheckTime(): ?string;
107+
108+
/**
109+
* Set last check time
110+
*
111+
* @param string $value
112+
* @return $this
113+
*/
114+
public function setLastCheckTime(string $value): ImsWebapiInterface;
115+
116+
/**
117+
* Get expires time of token
118+
*
119+
* @return string|null
120+
*/
121+
public function getAccessTokenExpiresAt(): ?string;
122+
123+
/**
124+
* Set expires time of token
125+
*
126+
* @param string $value
127+
* @return $this
128+
*/
129+
public function setAccessTokenExpiresAt(string $value): ImsWebapiInterface;
130+
131+
/**
132+
* Retrieve existing extension attributes object or create a new one.
133+
*
134+
* @return \Magento\AdminAdobeIms\Api\Data\ImsWebapiExtensionInterface
135+
*/
136+
public function getExtensionAttributes(): ImsWebapiExtensionInterface;
137+
138+
/**
139+
* Set extension attributes
140+
*
141+
* @param \Magento\AdminAdobeIms\Api\Data\ImsWebapiExtensionInterface $extensionAttributes
142+
* @return $this
143+
*/
144+
public function setExtensionAttributes(
145+
ImsWebapiExtensionInterface $extensionAttributes
146+
): ImsWebapiInterface;
147+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\AdminAdobeIms\Api\Data;
10+
11+
use Magento\AdminAdobeIms\Api\Data\ImsWebapiInterface;
12+
use Magento\Framework\Api\SearchResultsInterface;
13+
14+
/**
15+
* Interface ImsWebapiSearchResultsInterface
16+
*
17+
* @api
18+
*/
19+
interface ImsWebapiSearchResultsInterface extends SearchResultsInterface
20+
{
21+
/**
22+
* Get ims token list.
23+
*
24+
* @return ImsWebapiInterface[]
25+
*/
26+
public function getItems();
27+
28+
/**
29+
* Set ims token list.
30+
*
31+
* @param ImsWebapiInterface[] $items
32+
* @return $this
33+
*/
34+
public function setItems(array $items);
35+
}

app/code/Magento/AdminAdobeIms/Api/ImsLogOutInterface.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ interface ImsLogOutInterface
1919
* LogOut User from Adobe IMS Account
2020
*
2121
* @param string|null $accessToken
22-
* @param int|null $adminUserId
2322
* @return bool
2423
*/
25-
public function execute(?string $accessToken = null, ?int $adminUserId = null) : bool;
24+
public function execute(?string $accessToken = null) : bool;
2625
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\AdminAdobeIms\Api;
10+
11+
use Magento\AdminAdobeIms\Api\Data\ImsWebapiInterface;
12+
13+
use Magento\AdminAdobeIms\Api\Data\ImsWebapiSearchResultsInterface;
14+
use Magento\Framework\Api\SearchCriteriaInterface;
15+
use Magento\Framework\Exception\CouldNotSaveException;
16+
use Magento\Framework\Exception\LocalizedException;
17+
use Magento\Framework\Exception\NoSuchEntityException;
18+
19+
/**
20+
* Declare ims web api repository
21+
* @api
22+
*/
23+
interface ImsWebapiRepositoryInterface
24+
{
25+
/**
26+
* Save ims token
27+
*
28+
* @param ImsWebapiInterface $entity
29+
* @return void
30+
* @throws CouldNotSaveException
31+
*/
32+
public function save(ImsWebapiInterface $entity): void;
33+
34+
/**
35+
* Get ims token
36+
*
37+
* @param int $entityId
38+
* @return ImsWebapiInterface
39+
* @throws NoSuchEntityException
40+
*/
41+
public function get(int $entityId): ImsWebapiInterface;
42+
43+
/**
44+
* Get ims token(s) by admin user id
45+
*
46+
* @param int $adminUserId
47+
* @return ImsWebapiInterface[]
48+
* @throws NoSuchEntityException
49+
*/
50+
public function getByAdminUserId(int $adminUserId): array;
51+
52+
/**
53+
* Get entity by access token hash
54+
*
55+
* @param string $tokenHash
56+
* @return ImsWebapiInterface
57+
* @throws NoSuchEntityException
58+
*/
59+
public function getByAccessTokenHash(string $tokenHash): ImsWebapiInterface;
60+
61+
/**
62+
* Get ims token by search criteria
63+
*
64+
* @param SearchCriteriaInterface $searchCriteria
65+
* @return ImsWebapiSearchResultsInterface
66+
* @throws NoSuchEntityException
67+
*/
68+
public function getList(SearchCriteriaInterface $searchCriteria): ImsWebapiSearchResultsInterface;
69+
70+
/**
71+
* Delete ims tokens for admin user id.
72+
*
73+
* @param int $adminUserId
74+
* @return bool
75+
* @throws NoSuchEntityException
76+
* @throws LocalizedException
77+
*/
78+
public function deleteByAdminUserId(int $adminUserId): bool;
79+
}

app/code/Magento/AdminAdobeIms/Controller/Adminhtml/OAuth/ImsCallback.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use Exception;
1212
use Magento\AdminAdobeIms\Exception\AdobeImsOrganizationAuthorizationException;
13-
use Magento\AdminAdobeIms\Exception\AdobeImsTokenAuthorizationException;
13+
use Magento\AdminAdobeIms\Exception\AdobeImsAuthorizationException;
1414
use Magento\AdminAdobeIms\Logger\AdminAdobeImsLogger;
1515
use Magento\AdminAdobeIms\Service\AdminLoginProcessService;
1616
use Magento\AdminAdobeIms\Service\ImsConfig;
@@ -106,12 +106,12 @@ public function execute(): Redirect
106106
}
107107
$this->organizationService->checkOrganizationAllocation($profile);
108108
$this->adminLoginProcessService->execute($profile, $tokenResponse);
109-
} catch (AdobeImsTokenAuthorizationException $e) {
109+
} catch (AdobeImsAuthorizationException $e) {
110110
$this->logger->error($e->getMessage());
111111

112112
$this->imsErrorMessage(
113113
'You don\'t have access to this Commerce instance',
114-
AdobeImsTokenAuthorizationException::ERROR_MESSAGE
114+
AdobeImsAuthorizationException::ERROR_MESSAGE
115115
);
116116
} catch (AdobeImsOrganizationAuthorizationException $e) {
117117
$this->logger->error($e->getMessage());

app/code/Magento/AdminAdobeIms/Exception/AdobeImsTokenAuthorizationException.php renamed to app/code/Magento/AdminAdobeIms/Exception/AdobeImsAuthorizationException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* @api
1515
*/
16-
class AdobeImsTokenAuthorizationException extends AuthorizationException
16+
class AdobeImsAuthorizationException extends AuthorizationException
1717
{
1818
public const ERROR_MESSAGE = 'The Adobe ID you\'re using is not added to this Commerce instance. ' .
1919
'Contact your organization administrator to request access.';

0 commit comments

Comments
 (0)