1
0
mirror of synced 2025-02-16 20:23:15 +03:00

aliexpress.solution.product.schema.get support, a little refactoring in the models, correct PHP version in the annotations

This commit is contained in:
Pavel 2020-10-02 14:20:08 +03:00
parent e0790363a9
commit 15084614bf
45 changed files with 346 additions and 69 deletions

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category AuthorizationUriBuilder
* @package RetailCrm\Builder

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category TokenAuthenticator
* @package RetailCrm\Component\Authenticator

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category JsonDeserializationVisitorFactory
* @package RetailCrm\Component\JMS\Factory

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category JsonDeserializationVisitor
* @package RetailCrm\Component\JMS\Visitor\Deserialization

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category CategoryInfo
* @package RetailCrm\Model\Entity

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category AvailableResponseFormats
* @package RetailCrm\Model\Enum

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category AvailableSignMethods
* @package RetailCrm\Model\Enum

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category CategoryForecastSupportedLanguages
* @package RetailCrm\Model\Enum

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category FeedOperationTypes
* @package RetailCrm\Model\Enum

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category FeedStatuses
* @package RetailCrm\Model\Enum

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category SingleItemRequestDto
* @package RetailCrm\Model\Request\AliExpress\Data

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category PostproductRedefiningCategoryForecastResponse
* @package RetailCrm\Model\Request\AliExpress

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category SolutionFeedListGet
* @package RetailCrm\Model\Request\AliExpress

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category SolutionFeedQuery
* @package RetailCrm\Model\Request\AliExpress

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category SolutionFeedSubmit
* @package RetailCrm\Model\Request\AliExpress

View File

@ -0,0 +1,56 @@
<?php
/**
* PHP version 7.3
*
* @category SolutionProductSchemaGet
* @package RetailCrm\Model\Request\AliExpress
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
namespace RetailCrm\Model\Request\AliExpress;
use JMS\Serializer\Annotation as JMS;
use RetailCrm\Model\Request\BaseRequest;
use Symfony\Component\Validator\Constraints as Assert;
use RetailCrm\Model\Response\AliExpress\SolutionProductSchemaGetResponse;
/**
* Class SolutionProductSchemaGet
*
* @category SolutionProductSchemaGet
* @package RetailCrm\Model\Request\AliExpress
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/
class SolutionProductSchemaGet extends BaseRequest
{
/**
* @var int $aliexpressCategoryId
*
* @JMS\Type("int")
* @JMS\SerializedName("aliexpress_category_id")
* @Assert\NotBlank()
*/
public $aliexpressCategoryId;
/**
* @inheritDoc
*/
public function getMethod(): string
{
return 'aliexpress.solution.product.schema.get';
}
/**
* @inheritDoc
*/
public function getExpectedResponse(): string
{
return SolutionProductSchemaGetResponse::class;
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category SolutionSellerCategoryTreeQuery
* @package RetailCrm\Model\Request\AliExpress

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category AbstractResponseData
* @package RetailCrm\Model\Response

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category PostproductRedefiningCategoryForecastResponseData
* @package RetailCrm\Model\Response\AliExpress\Data

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category SolutionFeedListGetResponseData
* @package RetailCrm\Model\Response\AliExpress\Data

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category SolutionFeedQueryResponseData
* @package RetailCrm\Model\Response\AliExpress\Data

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category SolutionFeedSubmitResponseData
* @package RetailCrm\Model\Response\AliExpress\Data

View File

@ -0,0 +1,36 @@
<?php
/**
* PHP version 7.3
*
* @category SolutionProductSchemaGetResponseData
* @package RetailCrm\Model\Response\AliExpress\Data
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
namespace RetailCrm\Model\Response\AliExpress\Data;
use JMS\Serializer\Annotation as JMS;
/**
* Class SolutionProductSchemaGetResponseData
*
* @category SolutionProductSchemaGetResponseData
* @package RetailCrm\Model\Response\AliExpress\Data
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/
class SolutionProductSchemaGetResponseData
{
/**
* @var \RetailCrm\Model\Response\AliExpress\Result\SolutionProductSchemaGetResponseResult $result
*
* @JMS\Type("RetailCrm\Model\Response\AliExpress\Result\SolutionProductSchemaGetResponseResult")
* @JMS\SerializedName("result")
*/
public $result;
}

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category SolutionSellerCategoryTreeQueryResponseData
* @package RetailCrm\Model\Response\AliExpress\Data

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category SolutionSellerCategoryTreeQueryResponseDataChildrenCategoryList
* @package RetailCrm\Model\Response\AliExpress\Data

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category PostproductRedefiningCategoryForecastResponse
* @package RetailCrm\Model\Response\AliExpress

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category AeopCategoryForecastResultDto
* @package RetailCrm\Model\Response\AliExpress\Result
@ -13,6 +13,8 @@
namespace RetailCrm\Model\Response\AliExpress\Result;
use JMS\Serializer\Annotation as JMS;
use RetailCrm\Model\Response\AliExpress\Result\Traits\ErrorTrait;
use RetailCrm\Model\Response\AliExpress\Result\Traits\SuccessTrait;
/**
* Class AeopCategoryForecastResultDto
@ -26,13 +28,8 @@ use JMS\Serializer\Annotation as JMS;
*/
class AeopCategoryForecastResultDto
{
/**
* @var string $errorMessage
*
* @JMS\Type("string")
* @JMS\SerializedName("error_message")
*/
public $errorMessage;
use ErrorTrait;
use SuccessTrait;
/**
* @var \RetailCrm\Model\Response\AliExpress\Result\Entity\CategorySuitabilityList $categorySuitabilityList
@ -49,20 +46,4 @@ class AeopCategoryForecastResultDto
* @JMS\SerializedName("time_stamp")
*/
public $timeStamp;
/**
* @var string $errorCode
*
* @JMS\Type("string")
* @JMS\SerializedName("error_code")
*/
public $errorCode;
/**
* @var bool $success
*
* @JMS\Type("bool")
* @JMS\SerializedName("success")
*/
public $success;
}

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category BatchOperationJobDto
* @package RetailCrm\Model\Response\AliExpress\Result

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category CategorySuitabilityDto
* @package RetailCrm\Model\Response\AliExpress\Result

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category BatchOperationJobDtoList
* @package RetailCrm\Model\Response\AliExpress\Result\Entity

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category CategorySuitabilityList
* @package RetailCrm\Model\Response\AliExpress\Result\Entity

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category SingleItemResponseDtoList
* @package RetailCrm\Model\Response\AliExpress\Result\Entity

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category ItemExecutionResult
* @package RetailCrm\Model\Response\AliExpress\Result
@ -13,6 +13,7 @@
namespace RetailCrm\Model\Response\AliExpress\Result;
use JMS\Serializer\Annotation as JMS;
use RetailCrm\Model\Response\AliExpress\Result\Traits\SuccessTrait;
/**
* Class ItemExecutionResult
@ -26,6 +27,8 @@ use JMS\Serializer\Annotation as JMS;
*/
class ItemExecutionResult
{
use SuccessTrait;
/**
* @var int $productId
*
@ -33,12 +36,4 @@ class ItemExecutionResult
* @JMS\SerializedName("productId")
*/
public $productId;
/**
* @var bool $success
*
* @JMS\Type("bool")
* @JMS\SerializedName("success")
*/
public $success;
}

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category SingleItemResponseDto
* @package RetailCrm\Model\Response\AliExpress\Result

View File

@ -0,0 +1,43 @@
<?php
/**
* PHP version 7.3
*
* @category SolutionProductSchemaGetResponseResult
* @package RetailCrm\Model\Response\AliExpress\Result
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
namespace RetailCrm\Model\Response\AliExpress\Result;
use JMS\Serializer\Annotation as JMS;
use RetailCrm\Model\Response\AliExpress\Result\Traits\ErrorTrait;
use RetailCrm\Model\Response\AliExpress\Result\Traits\SuccessTrait;
/**
* Class SolutionProductSchemaGetResponseResult
*
* @category SolutionProductSchemaGetResponseResult
* @package RetailCrm\Model\Response\AliExpress\Result
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/
class SolutionProductSchemaGetResponseResult
{
use ErrorTrait;
use SuccessTrait;
/**
* Product Schema in JSON Schema format. Shouldn't be deserialized.
*
* @var string $schema
*
* @JMS\Type("string")
* @JMS\SerializedName("schema")
*/
public $schema;
}

View File

@ -0,0 +1,44 @@
<?php
/**
* PHP version 7.3
*
* @category ErrorTrait
* @package RetailCrm\Model\Response\AliExpress\Result\Traits
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
namespace RetailCrm\Model\Response\AliExpress\Result\Traits;
use JMS\Serializer\Annotation as JMS;
/**
* Trait ErrorTrait
*
* @category ErrorTrait
* @package RetailCrm\Model\Response\AliExpress\Result\Traits
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/
trait ErrorTrait
{
/**
* @var string $errorCode
*
* @JMS\Type("string")
* @JMS\SerializedName("error_code")
*/
public $errorCode;
/**
* @var string $errorMessage
*
* @JMS\Type("string")
* @JMS\SerializedName("error_message")
*/
public $errorMessage;
}

View File

@ -0,0 +1,36 @@
<?php
/**
* PHP version 7.3
*
* @category SuccessTrait
* @package RetailCrm\Model\Response\AliExpress\Result\Traits
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
namespace RetailCrm\Model\Response\AliExpress\Result\Traits;
use JMS\Serializer\Annotation as JMS;
/**
* Trait SuccessTrait
*
* @category SuccessTrait
* @package RetailCrm\Model\Response\AliExpress\Result\Traits
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/
trait SuccessTrait
{
/**
* @var bool $success
*
* @JMS\Type("bool")
* @JMS\SerializedName("success")
*/
public $success;
}

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category SolutionFeedListGetResponse
* @package RetailCrm\Model\Response\AliExpress

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category SolutionFeedQueryResponse
* @package RetailCrm\Model\Response\AliExpress

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category SolutionFeedSubmitResponse
* @package RetailCrm\Model\Response\AliExpress

View File

@ -0,0 +1,38 @@
<?php
/**
* PHP version 7.3
*
* @category SolutionProductSchemaGetResponse
* @package RetailCrm\Model\Response\AliExpress
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
namespace RetailCrm\Model\Response\AliExpress;
use RetailCrm\Model\Response\AliExpress\Data\SolutionProductSchemaGetResponseData;
use RetailCrm\Model\Response\BaseResponse;
use JMS\Serializer\Annotation as JMS;
/**
* Class SolutionProductSchemaGetResponse
*
* @category SolutionProductSchemaGetResponse
* @package RetailCrm\Model\Response\AliExpress
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license https://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/
class SolutionProductSchemaGetResponse extends BaseResponse
{
/**
* @var SolutionProductSchemaGetResponseData $responseData
*
* @JMS\Type("RetailCrm\Model\Response\AliExpress\Data\SolutionProductSchemaGetResponseData")
* @JMS\SerializedName("aliexpress_solution_product_schema_get_response")
*/
public $responseData;
}

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category SolutionSellerCategoryTreeQueryResponse
* @package RetailCrm\Model\Response\AliExpressSolution

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 7.4
* PHP version 7.3
*
* @category HttpDnsEnvEntry
* @package RetailCrm\Model\Response\Type

View File

@ -13,7 +13,6 @@
namespace RetailCrm\Service;
use JMS\Serializer\SerializerInterface;
use RetailCrm\Component\Constants;
use RetailCrm\Component\Exception\NotImplementedException;
use RetailCrm\Interfaces\AppDataInterface;
use RetailCrm\Interfaces\RequestSignerInterface;
@ -29,6 +28,14 @@ use RetailCrm\Model\Request\BaseRequest;
* @license MIT https://mit-license.org
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*
*TODO
* AliExpress TOP API won't accept signature generated by this component (it returns 'Invalid signature' error message).
* But I used incorrect session token (it can be found in the .env.dist file) - maybe, that's the problem.
* I cannot obtain session token via authorization URL (it says I don't have redirect URL, but it's present in the URL).
* This NEEDS to be checked, and if the problem remains even with the correct session token, it must be fixed.
* Request signing is a vital part of this library. If it doesn't work properly, then this library suddenly
* turns into pile of garbage.
*/
class RequestSigner implements RequestSignerInterface
{

View File

@ -26,6 +26,7 @@ use RetailCrm\Model\Request\AliExpress\PostproductRedefiningCategoryForecast;
use RetailCrm\Model\Request\AliExpress\SolutionFeedListGet;
use RetailCrm\Model\Request\AliExpress\SolutionFeedQuery;
use RetailCrm\Model\Request\AliExpress\SolutionFeedSubmit;
use RetailCrm\Model\Request\AliExpress\SolutionProductSchemaGet;
use RetailCrm\Model\Request\AliExpress\SolutionSellerCategoryTreeQuery;
use RetailCrm\Model\Request\Taobao\HttpDnsGetRequest;
use RetailCrm\Model\Response\AliExpress\Data\SolutionFeedSubmitResponseData;
@ -34,6 +35,7 @@ use RetailCrm\Model\Response\AliExpress\Data\SolutionSellerCategoryTreeQueryResp
use RetailCrm\Model\Response\AliExpress\PostproductRedefiningCategoryForecastResponse;
use RetailCrm\Model\Response\AliExpress\SolutionFeedListGetResponse;
use RetailCrm\Model\Response\AliExpress\SolutionFeedSubmitResponse;
use RetailCrm\Model\Response\AliExpress\SolutionProductSchemaGetResponse;
use RetailCrm\Model\Response\AliExpress\SolutionSellerCategoryTreeQueryResponse;
use RetailCrm\Model\Response\ErrorResponseBody;
use RetailCrm\Model\Response\Taobao\HttpDnsGetResponse;
@ -427,4 +429,43 @@ EOF;
self::assertEquals(FeedOperationTypes::PRODUCT_CREATE, $item->operationType);
self::assertEquals(2000000000123456, $item->jobId);
}
public function testAliexpressSolutionProductSchemaGet()
{
$json = <<<'EOF'
{
"aliexpress_solution_product_schema_get_response":{
"result":{
"success":true,
"error_code":"F00-00-10007-007",
"error_message":"duplicate sku_code, please check your input",
"schema":"{}"
}
}
}
EOF;
$mock = self::getMockClient();
$mock->on(
RequestMatcher::createMatcher('api.taobao.com')
->setPath('/router/rest')
->setOptionalQueryParams([
'app_key' => self::getEnvAppKey(),
'method' => 'aliexpress.solution.product.schema.get',
'session' => self::getEnvToken()
]),
$this->responseJson(200, $json)
);
$client = ClientBuilder::create()
->setContainer($this->getContainer($mock))
->setAppData($this->getEnvAppData())
->setAuthenticator($this->getEnvTokenAuthenticator())
->build();
$request = new SolutionProductSchemaGet();
$request->aliexpressCategoryId = 1;
/** @var SolutionProductSchemaGetResponse $response */
$response = $client->sendAuthenticatedRequest($request);
self::assertEquals('{}', $response->responseData->result->schema);
}
}