comments fix

This commit is contained in:
Artem Bondarenko 2020-10-15 22:36:26 +03:00 committed by David Garcia
parent c48f246942
commit 87c59dc386
6 changed files with 17 additions and 26 deletions

View File

@ -323,7 +323,8 @@ class Domain extends HttpApi
/** /**
* Updates a domain click tracking settings. * Updates a domain click tracking settings.
* *
* @param string $domain name of the domain * @param string $domain The name of the domain
* @param string $active The status for this tracking (one of: yes, no)
* *
* @return UpdateClickTrackingResponse|array|ResponseInterface * @return UpdateClickTrackingResponse|array|ResponseInterface
* *
@ -347,7 +348,8 @@ class Domain extends HttpApi
/** /**
* Updates a domain open tracking settings. * Updates a domain open tracking settings.
* *
* @param string $domain name of the domain * @param string $domain The name of the domain
* @param string $active The status for this tracking (one of: yes, no)
* *
* @return UpdateOpenTrackingResponse|array|ResponseInterface * @return UpdateOpenTrackingResponse|array|ResponseInterface
*/ */
@ -369,7 +371,10 @@ class Domain extends HttpApi
/** /**
* Updates a domain unsubscribe tracking settings. * Updates a domain unsubscribe tracking settings.
* *
* @param string $domain name of the domain * @param string $domain The name of the domain
* @param string $active The status for this tracking (one of: yes, no)
* @param string $htmlFooter The footer for HTML emails
* @param string $textFooter The footer for plain text emails
* *
* @return UpdateUnsubscribeTrackingResponse|array|ResponseInterface * @return UpdateUnsubscribeTrackingResponse|array|ResponseInterface
* *

View File

@ -22,16 +22,9 @@ final class ClickTracking
public static function create(array $data): self public static function create(array $data): self
{ {
$model = new self();
$active = $data['active'] ?? null; $active = $data['active'] ?? null;
$model = new self();
if (true === $active) { $model->active = 'htmlonly' === $active ? $active : ($active ? 'yes' : 'no');
$model->active = 'yes';
} elseif (false === $active) {
$model->active = 'no';
} else {
$model->active = $active;
}
return $model; return $model;
} }

View File

@ -22,16 +22,9 @@ final class OpenTracking
public static function create(array $data): self public static function create(array $data): self
{ {
$model = new self();
$active = $data['active'] ?? null; $active = $data['active'] ?? null;
$model = new self();
if (true === $active) { $model->active = $active ? 'yes' : 'no';
$model->active = 'yes';
} elseif (false === $active) {
$model->active = 'no';
} else {
$model->active = $active;
}
return $model; return $model;
} }

View File

@ -25,7 +25,7 @@ final class UnsubscribeTracking
public static function create(array $data): self public static function create(array $data): self
{ {
$model = new self(); $model = new self();
$model->active = ($data['active'] ?? null) ? 'true' : 'false'; $model->active = ($data['active'] ?? null) ? 'yes' : 'no';
$model->htmlFooter = $data['html_footer'] ?? ''; $model->htmlFooter = $data['html_footer'] ?? '';
$model->textFooter = $data['text_footer'] ?? ''; $model->textFooter = $data['text_footer'] ?? '';
@ -38,7 +38,7 @@ final class UnsubscribeTracking
public function isActive(): bool public function isActive(): bool
{ {
return 'true' === $this->getActive(); return 'yes' === $this->getActive();
} }
public function getActive(): string public function getActive(): string

View File

@ -29,7 +29,7 @@ class TrackingResponseTest extends BaseModelTest
"active": "htmlonly" "active": "htmlonly"
}, },
"open": { "open": {
"active": "no" "active": false
}, },
"unsubscribe": { "unsubscribe": {
"active": false, "active": false,
@ -53,7 +53,7 @@ JSON;
$this->assertNotEmpty($model->getUnsubscribe()); $this->assertNotEmpty($model->getUnsubscribe());
$this->assertInstanceOf(UnsubscribeTracking::class, $model->getUnsubscribe()); $this->assertInstanceOf(UnsubscribeTracking::class, $model->getUnsubscribe());
$this->assertEquals('false', $model->getUnsubscribe()->getActive()); $this->assertEquals('no', $model->getUnsubscribe()->getActive());
$this->assertFalse($model->getUnsubscribe()->isActive()); $this->assertFalse($model->getUnsubscribe()->isActive());
$this->assertEquals('<s>Test</s>', $model->getUnsubscribe()->getHtmlFooter()); $this->assertEquals('<s>Test</s>', $model->getUnsubscribe()->getHtmlFooter());
$this->assertEquals('Test', $model->getUnsubscribe()->getTextFooter()); $this->assertEquals('Test', $model->getUnsubscribe()->getTextFooter());

View File

@ -23,7 +23,7 @@ class UpdateOpenTrackingResponseTest extends BaseModelTest
<<<'JSON' <<<'JSON'
{ {
"open": { "open": {
"active": "no" "active": false
}, },
"message": "Domain tracking settings have been updated" "message": "Domain tracking settings have been updated"
} }