Skip to content

Commit

Permalink
Merge pull request #72 from avadev/release/2.5.0
Browse files Browse the repository at this point in the history
release/2.5.0
  • Loading branch information
avl-asheesh-singh authored Feb 17, 2023
2 parents 6398a48 + 6a42c51 commit 8c47cee
Show file tree
Hide file tree
Showing 109 changed files with 1,417 additions and 159 deletions.
18 changes: 18 additions & 0 deletions Api/RestCustomerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,24 @@ public function deleteCertificate(
$scopeType = \Magento\Store\Model\ScopeInterface::SCOPE_STORE
);

/**
* Perform REST request to unlink certificate.
*
* @param DataObject $request
* @param bool|null $isProduction
* @param string|int|null $scopeId
* @param string $scopeType
*
* @return mixed
* @throws \ClassyLlama\AvaTax\Exception\AvataxConnectionException
*/
public function unlinkCertificate(
$request,
$isProduction = null,
$scopeId = null,
$scopeType = \Magento\Store\Model\ScopeInterface::SCOPE_STORE
);

/**
* Perform REST request to update a customer.
*
Expand Down
19 changes: 18 additions & 1 deletion BaseProvider/Framework/Rest/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use GuzzleHttp\ClientFactory;
use GuzzleHttp\Psr7\ResponseFactory;
use Magento\Framework\Webapi\Rest\Request;
use ClassyLlama\AvaTax\Helper\ApiLog;

/**
* Class ApiClient
Expand Down Expand Up @@ -58,20 +59,28 @@ class ApiClient
protected $appVersion;
protected $machineName;
protected $authType;

/**
* @var ApiLog
*/
protected $apiLog;

/**
* GitApiService constructor
*
* @param ClientFactory $clientFactory
* @param ResponseFactory $responseFactory
* @param ApiLog $apiLog
*/
public function __construct(
ClientFactory $clientFactory,
ResponseFactory $responseFactory
ResponseFactory $responseFactory,
ApiLog $apiLog
) {
$this->clientFactory = $clientFactory;
$this->responseFactory = $responseFactory;
$this->catchExceptions = true;
$this->apiLog = $apiLog;
}

/**
Expand Down Expand Up @@ -159,6 +168,14 @@ public function restCall(
return $body;
}
} catch (\Exception $e) {

$debugLogContext = [];
$debugLogContext['message'] = $e->getMessage();
$debugLogContext['source'] = 'restCall';
$debugLogContext['operation'] = 'BaseProvider_Framework_Rest_ApiClient';
$debugLogContext['function_name'] = 'restCall';
$this->apiLog->debugLog($debugLogContext);

if (!$this->catchExceptions) {
throw $e;
}
Expand Down
17 changes: 16 additions & 1 deletion BaseProvider/Model/Log/Clear.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use ClassyLlama\AvaTax\BaseProvider\Helper\Application\Config as ApplicationLoggerConfig;
use ClassyLlama\AvaTax\BaseProvider\Model\ResourceModel\Log\CollectionFactory as LogCollFactory;
use Magento\Framework\Stdlib\DateTime\DateTime;
use ClassyLlama\AvaTax\Helper\ApiLog;

class Clear
{
Expand All @@ -40,23 +41,31 @@ class Clear
* @var DateTime
*/
protected $dateTime;

/**
* @var ApiLog
*/
protected $apiLog;

/**
* @param LoggerInterface $applicationLogger
* @param ApplicationLoggerConfig $applicationLoggerConfig
* @param LogCollFactory $logCollFactory
* @param DateTime $dateTime
* @param ApiLog $apiLog
*/
public function __construct(
LoggerInterface $applicationLogger,
ApplicationLoggerConfig $applicationLoggerConfig,
LogCollFactory $logCollFactory,
DateTime $dateTime
DateTime $dateTime,
ApiLog $apiLog
) {
$this->applicationLogger = $applicationLogger;
$this->applicationLoggerConfig = $applicationLoggerConfig;
$this->logCollFactory = $logCollFactory;
$this->dateTime = $dateTime;
$this->apiLog = $apiLog;
}

/**
Expand Down Expand Up @@ -100,6 +109,12 @@ public function clearDbLogs()
$log->delete();
$size++;
} catch(\Exception $e) {
$debugLogContext = [];
$debugLogContext['message'] = $e->getMessage();
$debugLogContext['source'] = 'clearlog';
$debugLogContext['operation'] = 'BaseProvider_Model_Log_Clear';
$debugLogContext['function_name'] = 'clearDbLogs';
$this->apiLog->debugLog($debugLogContext);
$e->getMessage();
}
}
Expand Down
17 changes: 16 additions & 1 deletion BaseProvider/Model/Queue/Clear.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use ClassyLlama\AvaTax\BaseProvider\Helper\Config as QueueConfig;
use ClassyLlama\AvaTax\BaseProvider\Model\ResourceModel\Queue\CollectionFactory as QueueCollFactory;
use Magento\Framework\Stdlib\DateTime\DateTime;
use ClassyLlama\AvaTax\Helper\ApiLog;

class Clear
{
Expand All @@ -42,22 +43,30 @@ class Clear
*/
protected $dateTime;

/**
* @var ApiLog
*/
protected $apiLog;

/**
* @param LoggerInterface
* @param QueueConfig $queueConfig
* @param QueueCollFactory $queueCollFactory
* @param DateTime $dateTime
* @param ApiLog $apiLog
*/
public function __construct(
LoggerInterface $logger,
QueueConfig $queueConfig,
QueueCollFactory $queueCollFactory,
DateTime $dateTime
DateTime $dateTime,
ApiLog $apiLog
) {
$this->logger = $logger;
$this->queueConfig = $queueConfig;
$this->queueCollFactory = $queueCollFactory;
$this->dateTime = $dateTime;
$this->apiLog = $apiLog;
}

/**
Expand Down Expand Up @@ -95,6 +104,12 @@ public function clearDbQueues()
$queue->delete();
$size++;
} catch(\Exception $e) {
$debugLogContext = [];
$debugLogContext['message'] = $e->getMessage();
$debugLogContext['source'] = 'clearqueue';
$debugLogContext['operation'] = 'BaseProvider_Model_Queue_Clear';
$debugLogContext['function_name'] = 'clearDbQueues';
$this->apiLog->debugLog($debugLogContext);
$this->logger->debug($e->getMessage());
}
}
Expand Down
20 changes: 11 additions & 9 deletions BaseProvider/Model/Queue/Consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,19 @@ public function __construct(
*/
public function process()
{
$this->logger->debug(__('Initiating queue processing from cron job'));
$size = $this->consumeJobs();
$this->logger->debug(
__('Completed queue processing from cron job.'),
[
'total_count' => $size,
'extra' => [
'class' => __METHOD__
if($size > 0)
{
$this->logger->debug(
__('Completed queue processing from cron job.'),
[
'total_count' => $size,
'extra' => [
'class' => __METHOD__
]
]
]
);
);
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions BaseProvider/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="baseprovider_log_listing_data_source" xsi:type="string">AvaTaxLogGridDataProvider</item>
<item name="baseprovider_log_listing_data_source" xsi:type="string">AvaTaxBaseProviderLogGridDataProvider</item>
</argument>
</arguments>
</type>
<virtualType name="AvaTaxLogGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
<virtualType name="AvaTaxBaseProviderLogGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">baseprovider_logs</argument>
<argument name="resourceModel" xsi:type="string">ClassyLlama\AvaTax\BaseProvider\Model\ResourceModel\Log</argument>
Expand Down
16 changes: 16 additions & 0 deletions Block/Adminhtml/Form/Field/TransportColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use Magento\Framework\DataObjectFactory;
use ClassyLlama\AvaTax\Api\RestDefinitionsInterface;
use ClassyLlama\AvaTax\Helper\Config;
use ClassyLlama\AvaTax\Helper\ApiLog;

/**
* @codeCoverageIgnore
*/
Expand All @@ -33,13 +35,19 @@ class TransportColumn extends Select
* @var RestDefinitionsInterface
*/
protected $definitionsService;
/**
* @var ApiLog
*/
protected $apiLog;

/**
* @param Context $context
* @param StoreManagerInterface $storeManager
* @param DataObjectFactory $dataObjectFactory
* @param RestDefinitionsInterface $definitionsService
* @param \Magento\Framework\Message\ManagerInterface $messageManager
* @param Config $config
* @param ApiLog $apiLog
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
Expand All @@ -48,6 +56,7 @@ public function __construct(
RestDefinitionsInterface $definitionsService,
\Magento\Framework\Message\ManagerInterface $messageManager,
Config $config,
ApiLog $apiLog,
array $data = []
)
{
Expand All @@ -57,6 +66,7 @@ public function __construct(
$this->definitionsService = $definitionsService;
$this->messageManager = $messageManager;
$this->config = $config;
$this->apiLog = $apiLog;
}

/**
Expand Down Expand Up @@ -111,6 +121,12 @@ private function getSourceOptions(): array
try {
$validateResult = $this->definitionsService->parameters($isProduction, $storeId);
} catch (\Exception $e) {
$debugLogContext = [];
$debugLogContext['message'] = $e->getMessage();
$debugLogContext['source'] = 'TransportColumn';
$debugLogContext['operation'] = 'Block_Adminhtml_Form_Field_TransportColumn';
$debugLogContext['function_name'] = 'getSourceOptions';
$this->apiLog->debugLog($debugLogContext, $storeId, $scopeType);
$this->messageManager->addError($e->getMessage());
return [];
}
Expand Down
16 changes: 8 additions & 8 deletions Block/ViewModel/CustomerCertificates.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ class CustomerCertificates implements \Magento\Framework\View\Element\Block\Argu
protected $urlBuilder;

/**
* @var \ClassyLlama\AvaTax\Helper\CertificateDeleteHelper
* @var \ClassyLlama\AvaTax\Helper\certificateUnlinkHelper
*/
protected $certificateDeleteHelper;
protected $certificateUnlinkHelper;

/**
* @var \ClassyLlama\AvaTax\Helper\CertificateHelper
Expand All @@ -79,7 +79,7 @@ class CustomerCertificates implements \Magento\Framework\View\Element\Block\Argu
* @param UrlSigner $urlSigner
* @param \ClassyLlama\AvaTax\Model\ResourceModel\Config $configResourceModel
* @param \Magento\Framework\UrlInterface $urlBuilder
* @param \ClassyLlama\AvaTax\Helper\CertificateDeleteHelper $certificateDeleteHelper
* @param \ClassyLlama\AvaTax\Helper\CertificateUnlinkHelper $certificateUnlinkHelper
* @param \ClassyLlama\AvaTax\Helper\CertificateHelper $certificateHelper
*/
public function __construct(
Expand All @@ -89,7 +89,7 @@ public function __construct(
UrlSigner $urlSigner,
\ClassyLlama\AvaTax\Model\ResourceModel\Config $configResourceModel,
\Magento\Framework\UrlInterface $urlBuilder,
\ClassyLlama\AvaTax\Helper\CertificateDeleteHelper $certificateDeleteHelper,
\ClassyLlama\AvaTax\Helper\CertificateUnlinkHelper $certificateUnlinkHelper,
\ClassyLlama\AvaTax\Helper\CertificateHelper $certificateHelper
)
{
Expand All @@ -99,7 +99,7 @@ public function __construct(
$this->urlSigner = $urlSigner;
$this->configResourceModel = $configResourceModel;
$this->urlBuilder = $urlBuilder;
$this->certificateDeleteHelper = $certificateDeleteHelper;
$this->certificateUnlinkHelper = $certificateUnlinkHelper;
$this->certificateHelper = $certificateHelper;
}

Expand Down Expand Up @@ -139,15 +139,15 @@ public function getCertificateUrl($certificateId)
}

/**
* Build delete cert url
* Build unlink cert url
*
* @param int $certificateId
*
* @return string
*/
public function getDeleteCertificateUrl(int $certificateId)
public function getUnlinkCertificateUrl(int $certificateId)
{
return $this->certificateHelper->getCertificateDeleteUrl($certificateId, $this->getCustomerId());
return $this->certificateHelper->getCertificateUnlinkUrl($certificateId, $this->getCustomerId());
}

/**
Expand Down
Loading

0 comments on commit 8c47cee

Please sign in to comment.