Skip to content

Commit

Permalink
Merge pull request #427 from magento-performance/cabpi-346
Browse files Browse the repository at this point in the history
CABPI-346, CABPI-348
  • Loading branch information
slopukhov authored Apr 19, 2022
2 parents 21ac01d + 5ff5557 commit 1bb7016
Show file tree
Hide file tree
Showing 30 changed files with 1,725 additions and 332 deletions.
147 changes: 147 additions & 0 deletions app/code/Magento/AdminAdobeIms/Api/Data/ImsWebapiInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\AdminAdobeIms\Api\Data;

use Magento\Framework\Api\ExtensibleDataInterface;

/**
* Declare the ims token data service object
* @api
*/
interface ImsWebapiInterface extends ExtensibleDataInterface
{
/**
* Get ID
*
* @return int|null
*/
public function getId();

/**
* Get admin user ID
*
* @return int|null
*/
public function getAdminUserId(): ?int;

/**
* Set admin user ID
*
* @param int $value
* @return $this
*/
public function setAdminUserId(int $value): ImsWebapiInterface;

/**
* Get access token hash
*
* @return string|null
*/
public function getAccessTokenHash(): ?string;

/**
* Set access token hash
*
* @param string $value
* @return $this
*/
public function setAccessTokenHash(string $value): ImsWebapiInterface;

/**
* Get access token
*
* @return string|null
*/
public function getAccessToken(): ?string;

/**
* Set access token
*
* @param string $value
* @return $this
*/
public function setAccessToken(string $value): ImsWebapiInterface;

/**
* Get creation time
*
* @return string|null
*/
public function getCreatedAt(): ?string;

/**
* Set creation time
*
* @param string $value
* @return $this
*/
public function setCreatedAt(string $value): ImsWebapiInterface;

/**
* Get update time
*
* @return string|null
*/
public function getUpdatedAt(): ?string;

/**
* Set update time
*
* @param string $value
* @return $this
*/
public function setUpdatedAt(string $value): ImsWebapiInterface;

/**
* Get last check time
*
* @return string|null
*/
public function getLastCheckTime(): ?string;

/**
* Set last check time
*
* @param string $value
* @return $this
*/
public function setLastCheckTime(string $value): ImsWebapiInterface;

/**
* Get expires time of token
*
* @return string|null
*/
public function getAccessTokenExpiresAt(): ?string;

/**
* Set expires time of token
*
* @param string $value
* @return $this
*/
public function setAccessTokenExpiresAt(string $value): ImsWebapiInterface;

/**
* Retrieve existing extension attributes object or create a new one.
*
* @return \Magento\AdminAdobeIms\Api\Data\ImsWebapiExtensionInterface
*/
public function getExtensionAttributes(): ImsWebapiExtensionInterface;

/**
* Set extension attributes
*
* @param \Magento\AdminAdobeIms\Api\Data\ImsWebapiExtensionInterface $extensionAttributes
* @return $this
*/
public function setExtensionAttributes(
ImsWebapiExtensionInterface $extensionAttributes
): ImsWebapiInterface;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\AdminAdobeIms\Api\Data;

use Magento\AdminAdobeIms\Api\Data\ImsWebapiInterface;
use Magento\Framework\Api\SearchResultsInterface;

/**
* Interface ImsWebapiSearchResultsInterface
*
* @api
*/
interface ImsWebapiSearchResultsInterface extends SearchResultsInterface
{
/**
* Get ims token list.
*
* @return ImsWebapiInterface[]
*/
public function getItems();

/**
* Set ims token list.
*
* @param ImsWebapiInterface[] $items
* @return $this
*/
public function setItems(array $items);
}
3 changes: 1 addition & 2 deletions app/code/Magento/AdminAdobeIms/Api/ImsLogOutInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ interface ImsLogOutInterface
* LogOut User from Adobe IMS Account
*
* @param string|null $accessToken
* @param int|null $adminUserId
* @return bool
*/
public function execute(?string $accessToken = null, ?int $adminUserId = null) : bool;
public function execute(?string $accessToken = null) : bool;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\AdminAdobeIms\Api;

use Magento\AdminAdobeIms\Api\Data\ImsWebapiInterface;

use Magento\AdminAdobeIms\Api\Data\ImsWebapiSearchResultsInterface;
use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;

/**
* Declare ims web api repository
* @api
*/
interface ImsWebapiRepositoryInterface
{
/**
* Save ims token
*
* @param ImsWebapiInterface $entity
* @return void
* @throws CouldNotSaveException
*/
public function save(ImsWebapiInterface $entity): void;

/**
* Get ims token
*
* @param int $entityId
* @return ImsWebapiInterface
* @throws NoSuchEntityException
*/
public function get(int $entityId): ImsWebapiInterface;

/**
* Get ims token(s) by admin user id
*
* @param int $adminUserId
* @return ImsWebapiInterface[]
* @throws NoSuchEntityException
*/
public function getByAdminUserId(int $adminUserId): array;

/**
* Get entity by access token hash
*
* @param string $tokenHash
* @return ImsWebapiInterface
* @throws NoSuchEntityException
*/
public function getByAccessTokenHash(string $tokenHash): ImsWebapiInterface;

/**
* Get ims token by search criteria
*
* @param SearchCriteriaInterface $searchCriteria
* @return ImsWebapiSearchResultsInterface
* @throws NoSuchEntityException
*/
public function getList(SearchCriteriaInterface $searchCriteria): ImsWebapiSearchResultsInterface;

/**
* Delete ims tokens for admin user id.
*
* @param int $adminUserId
* @return bool
* @throws NoSuchEntityException
* @throws LocalizedException
*/
public function deleteByAdminUserId(int $adminUserId): bool;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use Exception;
use Magento\AdminAdobeIms\Exception\AdobeImsOrganizationAuthorizationException;
use Magento\AdminAdobeIms\Exception\AdobeImsTokenAuthorizationException;
use Magento\AdminAdobeIms\Exception\AdobeImsAuthorizationException;
use Magento\AdminAdobeIms\Logger\AdminAdobeImsLogger;
use Magento\AdminAdobeIms\Service\AdminLoginProcessService;
use Magento\AdminAdobeIms\Service\ImsConfig;
Expand Down Expand Up @@ -106,12 +106,12 @@ public function execute(): Redirect
}
$this->organizationService->checkOrganizationAllocation($profile);
$this->adminLoginProcessService->execute($profile, $tokenResponse);
} catch (AdobeImsTokenAuthorizationException $e) {
} catch (AdobeImsAuthorizationException $e) {
$this->logger->error($e->getMessage());

$this->imsErrorMessage(
'You don\'t have access to this Commerce instance',
AdobeImsTokenAuthorizationException::ERROR_MESSAGE
AdobeImsAuthorizationException::ERROR_MESSAGE
);
} catch (AdobeImsOrganizationAuthorizationException $e) {
$this->logger->error($e->getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/**
* @api
*/
class AdobeImsTokenAuthorizationException extends AuthorizationException
class AdobeImsAuthorizationException extends AuthorizationException
{
public const ERROR_MESSAGE = 'The Adobe ID you\'re using is not added to this Commerce instance. ' .
'Contact your organization administrator to request access.';
Expand Down
Loading

0 comments on commit 1bb7016

Please sign in to comment.