Skip to content

Commit

Permalink
Merge pull request #78 from avadev/release/2.5.2
Browse files Browse the repository at this point in the history
release/2.5.2
  • Loading branch information
avl-asheesh-singh authored Apr 28, 2023
2 parents cb33cc9 + 2ceccab commit d18513a
Show file tree
Hide file tree
Showing 15 changed files with 120 additions and 13 deletions.
5 changes: 3 additions & 2 deletions BaseProvider/Framework/Rest/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
*/
class ApiClient
{
public $auth;

/**
* @var ResponseFactory
*/
Expand All @@ -41,7 +43,7 @@ class ApiClient
/**
* @var bool The setting for whether the client should catch exceptions
*/
protected $catchExceptions;
protected $catchExceptions = true;

/**
* @var Array Additional headers
Expand Down Expand Up @@ -79,7 +81,6 @@ public function __construct(
) {
$this->clientFactory = $clientFactory;
$this->responseFactory = $responseFactory;
$this->catchExceptions = true;
$this->apiLog = $apiLog;
}

Expand Down
5 changes: 5 additions & 0 deletions BaseProvider/Logger/Handler/Application/FileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ class FileHandler extends Base
*/
protected $loggerConfig;

/**
* @var array
*/
protected $processors = [];

/**
* @param Config $config
* @param DriverInterface $filesystem
Expand Down
5 changes: 5 additions & 0 deletions BaseProvider/Logger/Handler/BaseAbstractHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
*/
class BaseAbstractHandler extends AbstractHandler
{
/**
* @var array
*/
protected $processors = [];

public function __construct($level = Logger::DEBUG, $bubble = true)
{
parent::__construct($level, $bubble);
Expand Down
4 changes: 3 additions & 1 deletion BaseProvider/Model/QueueRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

class QueueRepository implements QueueRepositoryInterface
{
public $collectionFactory;

/**
* @var QueueFactory
*/
Expand Down Expand Up @@ -56,7 +58,7 @@ public function __construct(
$this->QueueFactory = $QueueFactory;
$this->QueueCollectionFactory = $QueueCollectionFactory;
$this->searchResultFactory = $QueueSearchResultsInterfaceFactory;
$this->collectionProcessor = collectionProcessor;
$this->collectionProcessor = $collectionProcessor;
}

public function getList(SearchCriteriaInterface $searchCriteria)
Expand Down
2 changes: 1 addition & 1 deletion Controller/Certificates/Unlink.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Unlink extends \Magento\Framework\App\Action\Action
/**
* @var \ClassyLlama\AvaTax\Helper\CertificateUnlinkHelper
*/
protected $CertificateUnlinkHelper;
protected $certificateUnlinkHelper;

/**
* Delete constructor.
Expand Down
2 changes: 1 addition & 1 deletion Framework/AppInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface AppInterface
/**
* Avalara APP String
*/
const CONNECTOR_STRING = 'a0o5a000007hWJMAA2';
const CONNECTOR_STRING = 'a0o5a000007m3XbAAI';
/**
* Avalara Connector name
*/
Expand Down
6 changes: 5 additions & 1 deletion Framework/Interaction/Rest/ClientPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ public function getClient(
}

$cacheKey = $this->getClientCacheKey($isProduction, $scopeType, $scopeId);

$guzzleParams = [];
$guzzleParams['timeout'] = $this->config->getAvaTaxApiTimeout(); // Response timeout
$guzzleParams['connect_timeout'] = $this->config->getAvaTaxApiTimeout(); // Connection timeout

if (!isset($this->clients[$cacheKey])) {
/** @var AvaTaxClientWrapper $avaTaxClient */
$avaTaxClient = $this->avaTaxClientFactory->create(
Expand All @@ -99,6 +102,7 @@ public function getClient(
'appVersion' => $this->config->getConnectorString(),
'machineName' => $this->config->getApplicationDomain(),
'environment' => $isProduction ? self::API_MODE_PROD : self::API_MODE_DEV,
'guzzleParams' => $guzzleParams
]
);

Expand Down
21 changes: 15 additions & 6 deletions Framework/Interaction/Rest/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use ClassyLlama\AvaTax\Framework\Interaction\Rest;
use ClassyLlama\AvaTax\Helper\Config;
use ClassyLlama\AvaTax\Helper\Customer as CustomerHelper;
use ClassyLlama\AvaTax\Model\Factory\LinkCertificatesModelFactory;
use ClassyLlama\AvaTax\Model\Factory\LinkCustomersModelFactory;
use Magento\Framework\DataObjectFactory;
use Psr\Log\LoggerInterface;
Expand All @@ -44,6 +45,11 @@ class Customer extends Rest implements RestCustomerInterface
*/
protected $config;

/**
* @var LinkCertificatesModelFactory
*/
protected $certificatesModelFactory;

/**
* @var LinkCustomersModelFactory
*/
Expand All @@ -62,6 +68,7 @@ class Customer extends Rest implements RestCustomerInterface
* @var ApiLog
*/
protected $apiLog;

/**
* @param CustomerHelper $customerHelper
* @param Config $config
Expand All @@ -70,6 +77,7 @@ class Customer extends Rest implements RestCustomerInterface
* @param ClientPool $clientPool
* @param \ClassyLlama\AvaTax\Model\Factory\CustomerModelFactory $customerModelFactory
* @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository
* @param LinkCertificatesModelFactory $certificatesModelFactory
* @param LinkCustomersModelFactory $customersModelFactory
* @param ApiLog $apiLog
*/
Expand All @@ -81,6 +89,7 @@ public function __construct(
ClientPool $clientPool,
\ClassyLlama\AvaTax\Model\Factory\CustomerModelFactory $customerModelFactory,
\Magento\Customer\Api\AddressRepositoryInterface $addressRepository,
LinkCertificatesModelFactory $certificatesModelFactory,
LinkCustomersModelFactory $customersModelFactory,
ApiLog $apiLog
) {
Expand All @@ -89,6 +98,7 @@ public function __construct(
$this->config = $config;
$this->customerModelFactory = $customerModelFactory;
$this->addressRepository = $addressRepository;
$this->certificatesModelFactory = $certificatesModelFactory;
$this->customersModelFactory = $customersModelFactory;
$this->apiLog = $apiLog;
}
Expand Down Expand Up @@ -198,17 +208,16 @@ public function unlinkCertificate(
$scopeId
);

//unlink request requires a LinkCustomersModel which contains a string[] of all customer ids.
/** @var \Avalara\LinkCustomersModel $customerModel */
//unlink request requires a LinkCertificatesModel which contains a string[] of all certificates ids.
/** @var \Avalara\LinkCertificatesModel $certificatesModel */
$certificateId = $request->getData('certificate_id');
$customerModel = $this->customersModelFactory->create();
$customerModel->certificates = [$certificateId];

$certificatesModel = $this->certificatesModelFactory->create();
$certificatesModel->certificates = [$certificateId];
//Customer(s) must be unlinked from cert before it can be deleted.
$client->unlinkCertificatesFromCustomer(
$this->config->getCompanyId($scopeId, $scopeType),
$customerId,
$customerModel
$certificatesModel
);
} catch (\Exception $e) {
$debugLogContext = [];
Expand Down
5 changes: 5 additions & 0 deletions Framework/Interaction/Rest/Definitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ class Definitions extends \ClassyLlama\AvaTax\Framework\Interaction\Rest

protected $definitionsResultFactory;

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

/**
* @param LoggerInterface $logger
* @param DataObjectFactory $dataObjectFactory
Expand Down
5 changes: 5 additions & 0 deletions Framework/Interaction/Tax.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ class Tax
*/
protected $scopeConfig;

/**
* @var \Magento\Framework\Serialize\Serializer\Json
*/
protected $serialize;

/**
* @param Address $address
* @param Config $config
Expand Down
6 changes: 6 additions & 0 deletions Helper/AvaTaxClientWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,17 @@ protected function restCall($apiUrl, $verb, $guzzleParams, $apiversion = '', $he
if (!isset($guzzleParams['timeout'])) {
$guzzleParams['timeout'] = $this->config->getAvaTaxApiTimeout();
}
if (!isset($guzzleParams['connect_timeout'])) {
$guzzleParams['connect_timeout'] = $this->config->getAvaTaxApiTimeout();
}

// Warning: This causes the value to revert to the default "forever" timeout in guzzle
if (\is_nan($guzzleParams['timeout'])) {
$guzzleParams['timeout'] = 0;
}
if (\is_nan($guzzleParams['connect_timeout'])) {
$guzzleParams['connect_timeout'] = 0;
}

return parent::restCall($apiUrl, $verb, $guzzleParams);
}
Expand Down
2 changes: 2 additions & 0 deletions Helper/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ class Config extends AbstractHelper
*/
const AVATAX_CACHE_TAG = 'AVATAX';

public $avaTaxConfigFactory;

/**
* @var ProductMetadataInterface
*/
Expand Down
62 changes: 62 additions & 0 deletions Model/Factory/LinkCertificatesModelFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/**
* ClassyLlama_AvaTax
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @copyright Copyright (c) 2018 Avalara, Inc.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

namespace ClassyLlama\AvaTax\Model\Factory;

/**
* Factory class for @see \Avalara\LinkCertificatesModel
*/
class LinkCertificatesModelFactory
{
/**
* Object Manager instance
*
* @var \Magento\Framework\ObjectManagerInterface
*/
protected $_objectManager = null;

/**
* Instance name to create
*
* @var string
*/
protected $_instanceName = null;

/**
* Factory constructor
*
* @param \Magento\Framework\ObjectManagerInterface $objectManager
* @param string $instanceName
*/
public function __construct(
\Magento\Framework\ObjectManagerInterface $objectManager,
$instanceName = '\\Avalara\\LinkCertificatesModel'
)
{
$this->_objectManager = $objectManager;
$this->_instanceName = $instanceName;
}

/**
* Create class instance with specified parameters
*
* @param array $data
* @return \Avalara\LinkCertificatesModel
*/
public function create(array $data = array())
{
return $this->_objectManager->create($this->_instanceName, $data);
}
}
1 change: 1 addition & 0 deletions etc/adminhtml/system/error_logs_and_queue.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
</depends>
</field>
<field id="avatax_timeout" translate="label comment" type="text" sortOrder="2050" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<config_path>tax/avatax_advanced/avatax_timeout</config_path>
<label>AvaTax API Timeout</label>
<comment><![CDATA[This field defines how long Magento should wait to hear from AvaTax's servers before assuming no response will be given.]]></comment>
</field>
Expand Down
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
</avatax_document_management>
<avatax_advanced>
<response_logging_enabled>1</response_logging_enabled>
<avatax_timeout>15</avatax_timeout>
<avatax_timeout>60</avatax_timeout>
<avatax_adjustment_taxes>0</avatax_adjustment_taxes>
<avatax_table_exemptions>negotiable_quote_item,company_order_entity</avatax_table_exemptions>
<result_cache_ttl>15</result_cache_ttl>
Expand Down

0 comments on commit d18513a

Please sign in to comment.