Skip to content

Commit

Permalink
Add working with customer utm
Browse files Browse the repository at this point in the history
  • Loading branch information
Chupocabra committed May 21, 2024
1 parent 6682b9b commit 5aaed7a
Show file tree
Hide file tree
Showing 4 changed files with 207 additions and 3 deletions.
26 changes: 26 additions & 0 deletions src/Bot/Model/Entity/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -406,4 +415,21 @@ public function setEmail(string $email)
{
$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;
}
}
154 changes: 154 additions & 0 deletions src/Bot/Model/Entity/Utm.php
Original file line number Diff line number Diff line change
@@ -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;
}
}
3 changes: 3 additions & 0 deletions tests/Bot/Tests/ClientListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,5 +252,8 @@ public function testCustomers()

self::assertCount(3, $response);
self::assertInstanceOf(Customer::class, $response[0]);

$utm = $response[0]->getUtm()->getCampaign();
static::assertEquals('spring_sale', $utm, "Incorrect utm data");
}
}
27 changes: 24 additions & 3 deletions tests/Resources/customers.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@
"country": "",
"language": "en",
"phone": "",
"email": ""
"email": "",
"utm": {
"campaign": "spring_sale",
"content": "textlink",
"medium": "cpc",
"source": "Google",
"term": "running"
}
},
{
"id": 38,
Expand All @@ -29,7 +36,14 @@
"country": "",
"language": "ru",
"phone": "",
"email": ""
"email": "",
"utm": {
"campaign": "test",
"content": "test",
"medium": "test",
"source": "test",
"term": "test"
}
},
{
"id": 37,
Expand All @@ -45,6 +59,13 @@
"country": "",
"language": "ru",
"phone": "",
"email": ""
"email": "",
"utm": {
"campaign": "",
"content": "",
"medium": "",
"source": "",
"term": ""
}
}
]

0 comments on commit 5aaed7a

Please sign in to comment.