1
0
mirror of synced 2024-11-24 21:46:02 +03:00

PSR-6 cache support for product schema caching & license tags fix

This commit is contained in:
Pavel 2020-10-02 16:24:57 +03:00
parent 96ee257498
commit 12410f5a40
48 changed files with 76 additions and 46 deletions

View File

@ -42,7 +42,8 @@ $response = $client->sendRequest(new HttpDnsGetRequest());
```
This particular request doesn't require authorization, so, it can be sent via `Client::sendRequest` method. For any other requests which require authorization you must use `Client::sendAuthenticatedRequest` method (an example of such request would be `aliexpress.solution.seller.category.tree.query`, which class FQN is `\RetailCrm\Model\Request\AliExpress\SolutionSellerCategoryTreeQuery`).
**Note:** use response type annotations. Both client methods which returns responses actually returns `ResponseInterface` (not the PSR one). Actual response type will be determined by the request model. Your IDE will not recognize any response options unless you put a proper type annotation for the response variable.
**Friendly note.** Use response type annotations. Both client methods which returns responses actually returns `ResponseInterface` (not the PSR one). Actual response type will be determined by the request model. Your IDE will not recognize any response options unless you put a proper type annotation for the response variable.
**Another friendly note.**
## Customization
This library uses Container pattern under the hood. You can pass additional dependencies using `ContainerBuilder`. For example:

View File

@ -32,7 +32,9 @@
"php-http/message-factory": "^1.0",
"php-http/discovery": "^1.12",
"php-http/multipart-stream-builder": "^1.1",
"symfony/expression-language": "^5.1"
"symfony/expression-language": "^5.1",
"psr/cache": "^1.0",
"cache/array-adapter": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^9.3",

View File

@ -21,7 +21,7 @@ use RetailCrm\Interfaces\BuilderInterface;
* @category AuthorizationUriBuilder
* @package RetailCrm\Builder
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -12,8 +12,10 @@
*/
namespace RetailCrm\Builder;
use Cache\Adapter\PHPArray\ArrayCachePool;
use Http\Discovery\Psr17FactoryDiscovery;
use Http\Discovery\Psr18ClientDiscovery;
use Psr\Cache\CacheItemPoolInterface;
use Psr\Container\ContainerInterface;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
@ -88,6 +90,9 @@ class ContainerBuilder implements BuilderInterface
*/
private $uriFactory;
/** @var CacheItemPoolInterface $cache */
private $cache;
/**
* @return static
*/
@ -162,6 +167,17 @@ class ContainerBuilder implements BuilderInterface
return $this;
}
/**
* @param \Psr\Cache\CacheItemPoolInterface $cache
*
* @return ContainerBuilder
*/
public function setCache(CacheItemPoolInterface $cache): ContainerBuilder
{
$this->cache = $cache;
return $this;
}
/**
* @return \Psr\Container\ContainerInterface
*/
@ -192,6 +208,7 @@ class ContainerBuilder implements BuilderInterface
{
$container->set(Constants::HTTP_CLIENT, $this->getHttpClient());
$container->set(Constants::LOGGER, $this->getLogger());
$container->set(Constants::CACHE, $this->getCache());
$container->set(StreamFactoryInterface::class, $this->getStreamFactory());
$container->set(RequestFactoryInterface::class, $this->getRequestFactory());
$container->set(UriFactoryInterface::class, $this->getUriFactory());
@ -292,4 +309,12 @@ class ContainerBuilder implements BuilderInterface
? $this->uriFactory
: Psr17FactoryDiscovery::findUriFactory();
}
/**
* @return \Psr\Cache\CacheItemPoolInterface
*/
protected function getCache(): CacheItemPoolInterface
{
return $this->cache instanceof CacheItemPoolInterface ? $this->cache : new ArrayCachePool();
}
}

View File

@ -21,7 +21,7 @@ use RetailCrm\Model\Request\BaseRequest;
* @category TokenAuthenticator
* @package RetailCrm\Component\Authenticator
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -27,6 +27,7 @@ class Constants
public const HTTP_CLIENT = 'httpClient';
public const SERIALIZER = 'serializer';
public const LOGGER = 'logger';
public const CACHE = 'cache';
public const VALIDATOR = 'validator';
public const TOP_VERSION = 'top-sdk-php-20180326';
public const UNSIGNED_MARK = '00000000000000000000000000000000';

View File

@ -22,7 +22,7 @@ use JMS\Serializer\Visitor\Factory\DeserializationVisitorFactory;
* @category JsonDeserializationVisitorFactory
* @package RetailCrm\Component\JMS\Factory
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -28,7 +28,7 @@ use SplStack;
* @category JsonDeserializationVisitor
* @package RetailCrm\Component\JMS\Visitor\Deserialization
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -20,7 +20,7 @@ use JMS\Serializer\Annotation as JMS;
* @category CategoryInfo
* @package RetailCrm\Model\Entity
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -18,7 +18,7 @@ namespace RetailCrm\Model\Enum;
* @category AvailableResponseFormats
* @package RetailCrm\Model\Enum
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -18,7 +18,7 @@ namespace RetailCrm\Model\Enum;
* @category AvailableSignMethods
* @package RetailCrm\Model\Enum
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -18,7 +18,7 @@ namespace RetailCrm\Model\Enum;
* @category CategoryForecastSupportedLanguages
* @package RetailCrm\Model\Enum
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -18,7 +18,7 @@ namespace RetailCrm\Model\Enum;
* @category FeedOperationTypes
* @package RetailCrm\Model\Enum
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -18,7 +18,7 @@ namespace RetailCrm\Model\Enum;
* @category FeedStatuses
* @package RetailCrm\Model\Enum
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -20,7 +20,7 @@ use JMS\Serializer\Annotation as JMS;
* @category SingleItemRequestDto
* @package RetailCrm\Model\Request\AliExpress\Data
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -23,7 +23,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* @category PostproductRedefiningCategoryForecastResponse
* @package RetailCrm\Model\Request\AliExpress
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -22,7 +22,7 @@ use RetailCrm\Model\Response\AliExpress\SolutionFeedListGetResponse;
* @category SolutionFeedListGet
* @package RetailCrm\Model\Request\AliExpress
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -22,7 +22,7 @@ use RetailCrm\Model\Response\AliExpress\SolutionFeedQueryResponse;
* @category SolutionFeedQuery
* @package RetailCrm\Model\Request\AliExpress
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -24,7 +24,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* @category SolutionFeedSubmit
* @package RetailCrm\Model\Request\AliExpress
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -23,7 +23,7 @@ use RetailCrm\Model\Response\AliExpress\SolutionProductSchemaGetResponse;
* @category SolutionProductSchemaGet
* @package RetailCrm\Model\Request\AliExpress
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -23,7 +23,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* @category SolutionSellerCategoryTreeQuery
* @package RetailCrm\Model\Request\AliExpress
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -20,7 +20,7 @@ use JMS\Serializer\Annotation as JMS;
* @category AbstractResponseData
* @package RetailCrm\Model\Response
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -21,7 +21,7 @@ use RetailCrm\Model\Response\AbstractResponseData;
* @category PostproductRedefiningCategoryForecastResponseData
* @package RetailCrm\Model\Response\AliExpress\Data
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -21,7 +21,7 @@ use JMS\Serializer\Annotation as JMS;
* @category SolutionFeedListGetResponseData
* @package RetailCrm\Model\Response\AliExpress\Data
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -21,7 +21,7 @@ use RetailCrm\Model\Response\AbstractResponseData;
* @category SolutionFeedQueryResponseData
* @package RetailCrm\Model\Response\AliExpress\Data
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -21,7 +21,7 @@ use JMS\Serializer\Annotation as JMS;
* @category SolutionFeedSubmitResponseData
* @package RetailCrm\Model\Response\AliExpress\Data
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -20,7 +20,7 @@ use JMS\Serializer\Annotation as JMS;
* @category SolutionProductSchemaGetResponseData
* @package RetailCrm\Model\Response\AliExpress\Data
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -21,7 +21,7 @@ use RetailCrm\Model\Response\AbstractResponseData;
* @category SolutionSellerCategoryTreeQueryResponseData
* @package RetailCrm\Model\Response\AliExpressSolution\Data
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -21,7 +21,7 @@ use JMS\Serializer\Annotation as JMS;
* @category SolutionSellerCategoryTreeQueryResponseDataChildrenCategoryList
* @package RetailCrm\Model\Response\AliExpress\Data
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -23,7 +23,7 @@ use JMS\Serializer\Annotation as JMS;
* @category PostproductRedefiningCategoryForecastResponse
* @package RetailCrm\Model\Response\AliExpress
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -22,7 +22,7 @@ use RetailCrm\Model\Response\AliExpress\Result\Traits\SuccessTrait;
* @category AeopCategoryForecastResultDto
* @package RetailCrm\Model\Response\AliExpress\Result
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -20,7 +20,7 @@ use JMS\Serializer\Annotation as JMS;
* @category BatchOperationJobDto
* @package RetailCrm\Model\Response\AliExpress\Result
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -20,7 +20,7 @@ use JMS\Serializer\Annotation as JMS;
* @category CategorySuitabilityDto
* @package RetailCrm\Model\Response\AliExpress\Result
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -20,7 +20,7 @@ use JMS\Serializer\Annotation as JMS;
* @category BatchOperationJobDtoList
* @package RetailCrm\Model\Response\AliExpress\Result\Entity
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -20,7 +20,7 @@ use JMS\Serializer\Annotation as JMS;
* @category CategorySuitabilityList
* @package RetailCrm\Model\Response\AliExpress\Result\Entity
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -20,7 +20,7 @@ use JMS\Serializer\Annotation as JMS;
* @category SingleItemResponseDtoList
* @package RetailCrm\Model\Response\AliExpress\Result\Entity
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -21,7 +21,7 @@ use RetailCrm\Model\Response\AliExpress\Result\Traits\SuccessTrait;
* @category ItemExecutionResult
* @package RetailCrm\Model\Response\AliExpress\Result
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -20,7 +20,7 @@ use JMS\Serializer\Annotation as JMS;
* @category SingleItemResponseDto
* @package RetailCrm\Model\Response\AliExpress\Result
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -22,7 +22,7 @@ use RetailCrm\Model\Response\AliExpress\Result\Traits\SuccessTrait;
* @category SolutionProductSchemaGetResponseResult
* @package RetailCrm\Model\Response\AliExpress\Result
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -20,7 +20,7 @@ use JMS\Serializer\Annotation as JMS;
* @category ErrorTrait
* @package RetailCrm\Model\Response\AliExpress\Result\Traits
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -20,7 +20,7 @@ use JMS\Serializer\Annotation as JMS;
* @category SuccessTrait
* @package RetailCrm\Model\Response\AliExpress\Result\Traits
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -21,7 +21,7 @@ use JMS\Serializer\Annotation as JMS;
* @category SolutionFeedListGetResponse
* @package RetailCrm\Model\Response\AliExpress
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -21,7 +21,7 @@ use JMS\Serializer\Annotation as JMS;
* @category SolutionFeedQueryResponse
* @package RetailCrm\Model\Response\AliExpress
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -21,7 +21,7 @@ use JMS\Serializer\Annotation as JMS;
* @category SolutionFeedSubmitResponse
* @package RetailCrm\Model\Response\AliExpress
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -22,7 +22,7 @@ use JMS\Serializer\Annotation as JMS;
* @category SolutionProductSchemaGetResponse
* @package RetailCrm\Model\Response\AliExpress
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -21,7 +21,7 @@ use JMS\Serializer\Annotation as JMS;
* @category SolutionSellerCategoryTreeQueryResponse
* @package RetailCrm\Model\Response\AliExpressSolution
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -20,7 +20,7 @@ use JMS\Serializer\Annotation as JMS;
* @category HttpDnsEnvEntry
* @package RetailCrm\Model\Response\Type
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/

View File

@ -14,6 +14,7 @@ namespace RetailCrm\TopClient;
use DateTime;
use JMS\Serializer\SerializerInterface;
use Psr\Cache\CacheItemPoolInterface;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\StreamInterface;
@ -95,7 +96,7 @@ class Client
*/
public function __construct(AppDataInterface $appData)
{
$this->appData = $appData;
$this->appData = $appData;
}
/**