diff --git a/src/Bot/Model/Entity/Customer.php b/src/Bot/Model/Entity/Customer.php index cc5162d..a6bc859 100644 --- a/src/Bot/Model/Entity/Customer.php +++ b/src/Bot/Model/Entity/Customer.php @@ -167,6 +167,15 @@ class Customer implements ModelInterface */ private $email; + /** + * @var Utm $utm + * + * @Type("RetailCrm\Mg\Bot\Model\Entity\Utm") + * @Accessor(getter="getUtm",setter="setUtm") + * @SkipWhenEmpty() + */ + private $utm; + /** * @return string|null */ @@ -406,4 +415,21 @@ class Customer implements ModelInterface { $this->email = $email; } + + /** + * @return Utm|null + */ + public function getUtm(): ?Utm + { + return $this->utm; + } + + /** + * @param Utm $utm + * @return void + */ + public function setUtm(Utm $utm): void + { + $this->utm = $utm; + } } diff --git a/src/Bot/Model/Entity/Utm.php b/src/Bot/Model/Entity/Utm.php new file mode 100644 index 0000000..de454d0 --- /dev/null +++ b/src/Bot/Model/Entity/Utm.php @@ -0,0 +1,154 @@ +campaign; + } + + /** + * @param string $campaign + * @return void + */ + public function setCampaign(string $campaign): void + { + $this->campaign = $campaign; + } + + /** + * @return string|null + */ + public function getContent(): ?string + { + return $this->content; + } + + /** + * @param string $content + * @return void + */ + public function setContent(string $content): void + { + $this->content = $content; + } + + /** + * @return string|null + */ + public function getMedium(): ?string + { + return $this->medium; + } + + /** + * @param string $medium + * @return void + */ + public function setMedium(string $medium): void + { + $this->medium = $medium; + } + + /** + * @return string|null + */ + public function getSource(): ?string + { + return $this->source; + } + + /** + * @param string $source + * @return void + */ + public function setSource(string $source): void + { + $this->source = $source; + } + + /** + * @return string|null + */ + public function getTerm(): ?string + { + return $this->term; + } + + /** + * @param string $term + * @return void + */ + public function setTerm(string $term): void + { + $this->term = $term; + } +} diff --git a/tests/Bot/Tests/ClientListTest.php b/tests/Bot/Tests/ClientListTest.php index 94694f3..fee5bce 100644 --- a/tests/Bot/Tests/ClientListTest.php +++ b/tests/Bot/Tests/ClientListTest.php @@ -252,5 +252,8 @@ class ClientListTest extends TestCase self::assertCount(3, $response); self::assertInstanceOf(Customer::class, $response[0]); + + $utm = $response[0]->getUtm()->getCampaign(); + static::assertEquals('spring_sale', $utm, "Incorrect utm data"); } } diff --git a/tests/Resources/customers.json b/tests/Resources/customers.json index 8a98480..744f632 100644 --- a/tests/Resources/customers.json +++ b/tests/Resources/customers.json @@ -13,7 +13,14 @@ "country": "", "language": "en", "phone": "", - "email": "" + "email": "", + "utm": { + "campaign": "spring_sale", + "content": "textlink", + "medium": "cpc", + "source": "Google", + "term": "running" + } }, { "id": 38, @@ -29,7 +36,14 @@ "country": "", "language": "ru", "phone": "", - "email": "" + "email": "", + "utm": { + "campaign": "test", + "content": "test", + "medium": "test", + "source": "test", + "term": "test" + } }, { "id": 37, @@ -45,6 +59,13 @@ "country": "", "language": "ru", "phone": "", - "email": "" + "email": "", + "utm": { + "campaign": "", + "content": "", + "medium": "", + "source": "", + "term": "" + } } ]