1
0
mirror of synced 2024-11-25 05:06:02 +03:00

Add working with customer utm

This commit is contained in:
Alex Komarichev 2024-05-21 20:19:22 +03:00
parent 6682b9b02c
commit 5aaed7ab7d
4 changed files with 207 additions and 3 deletions

View File

@ -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;
}
}

View File

@ -0,0 +1,154 @@
<?php
/**
* PHP version 7.1
*
* Utm entity
*
* @package Retailcrm\Mg\Bot\Model\Entity
*/
namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* Utm class
*
* @package RetailCrm\Mg\Bot\Model\Entity
*/
class Utm implements ModelInterface
{
/**
* @var string $campaign
*
* @Type("string")
* @Accessor(getter="getCampaign",setter="setCampaign")
* @SkipWhenEmpty()
*/
private $campaign;
/**
* @var string $content
*
* @Type("string")
* @Accessor(getter="getContent",setter="setContent")
* @SkipWhenEmpty()
*/
private $content;
/**
* @var string $medium
*
* @Type("string")
* @Accessor(getter="getMedium",setter="setMedium")
* @SkipWhenEmpty()
*/
private $medium;
/**
* @var string $source
*
* @Type("string")
* @Accessor(getter="getSource",setter="setSource")
* @SkipWhenEmpty()
*/
private $source;
/**
* @var string $term
*
* @Type("string")
* @Accessor(getter="getTerm",setter="setTerm")
* @SkipWhenEmpty()
*/
private $term;
/**
* @return string|null
*/
public function getCampaign(): ?string
{
return $this->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;
}
}

View File

@ -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");
}
}

View File

@ -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": ""
}
}
]