fix customer tags support
This commit is contained in:
parent
4de6a3b798
commit
232c22a557
@ -23,6 +23,7 @@ use RetailCrm\Api\Component\Serializer\Template\CustomSerialization;
|
||||
use RetailCrm\Api\Component\Serializer\Type\PropertyTypeMixed;
|
||||
use RetailCrm\Api\Interfaces\Orders\CustomerInterface;
|
||||
use RetailCrm\Api\Model\Entity\Customers\Customer;
|
||||
use RetailCrm\Api\Model\Entity\Customers\CustomerTag;
|
||||
use RetailCrm\Api\Model\Entity\CustomersCorporate\CustomerCorporate;
|
||||
use RetailCrm\Api\Model\Entity\CustomersCorporate\SerializedRelationAbstractCustomer;
|
||||
use RetailCrm\Api\Model\Entity\Orders\SerializedRelationCustomer;
|
||||
@ -152,6 +153,10 @@ final class SerializerGenerator
|
||||
);
|
||||
}
|
||||
|
||||
if ($classMetadata->getClassName() === CustomerTag::class) {
|
||||
return $this->generateForCustomerTag($arrayPath, $modelPath);
|
||||
}
|
||||
|
||||
$stack[$classMetadata->getClassName()] = ($stack[$classMetadata->getClassName()] ?? 0) + 1;
|
||||
|
||||
$code = '';
|
||||
@ -242,6 +247,17 @@ final class SerializerGenerator
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $arrayPath
|
||||
* @param string $modelPath
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function generateForCustomerTag(string $arrayPath, string $modelPath): string
|
||||
{
|
||||
return $this->templating->renderAssign($arrayPath, $modelPath . '->name');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $serializerGroups
|
||||
* @param array<string, positive-int> $stack
|
||||
|
@ -2698,15 +2698,14 @@ EOF;
|
||||
$response = $client->customers->get(4770, $request);
|
||||
|
||||
self::assertModelsCallback($json, $response, static function ($expected, $actual) {
|
||||
// TODO: Check if it's really necessary to do tag conversion here. Maybe underlying serializer is broken.
|
||||
// $actualTags = $actual['customer']['tags'];
|
||||
// $actual['customer']['tags'] = array_filter(
|
||||
// array_map(static function ($tag) use ($actualTags) {
|
||||
// if (in_array($tag['name'], $actualTags, true)) {
|
||||
// return $tag;
|
||||
// }
|
||||
// }, $expected['customer']['tags'])
|
||||
// );
|
||||
$actualTags = $actual['customer']['tags'];
|
||||
$actual['customer']['tags'] = array_filter(
|
||||
array_map(static function ($tag) use ($actualTags) {
|
||||
if (in_array($tag['name'], $actualTags, true)) {
|
||||
return $tag;
|
||||
}
|
||||
}, $expected['customer']['tags'])
|
||||
);
|
||||
|
||||
$expected['customer']['marginSumm'] = (float)$expected['customer']['marginSumm'];
|
||||
$expected['customer']['totalSumm'] = (float)$expected['customer']['totalSumm'];
|
||||
|
Loading…
Reference in New Issue
Block a user