From 87c59dc38663f57c00906cbffc2e7bf803b3a43e Mon Sep 17 00:00:00 2001 From: Artem Bondarenko Date: Thu, 15 Oct 2020 22:36:26 +0300 Subject: [PATCH] comments fix --- src/Api/Domain.php | 11 ++++++++--- src/Model/Domain/ClickTracking.php | 11 ++--------- src/Model/Domain/OpenTracking.php | 11 ++--------- src/Model/Domain/UnsubscribeTracking.php | 4 ++-- tests/Model/Domain/TrackingResponseTest.php | 4 ++-- tests/Model/Domain/UpdateOpenTrackingResponseTest.php | 2 +- 6 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/Api/Domain.php b/src/Api/Domain.php index c111d8d..ba73fe5 100644 --- a/src/Api/Domain.php +++ b/src/Api/Domain.php @@ -323,7 +323,8 @@ class Domain extends HttpApi /** * 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 * @@ -347,7 +348,8 @@ class Domain extends HttpApi /** * 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 */ @@ -369,7 +371,10 @@ class Domain extends HttpApi /** * 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 * diff --git a/src/Model/Domain/ClickTracking.php b/src/Model/Domain/ClickTracking.php index c5ae3a6..432536c 100644 --- a/src/Model/Domain/ClickTracking.php +++ b/src/Model/Domain/ClickTracking.php @@ -22,16 +22,9 @@ final class ClickTracking public static function create(array $data): self { - $model = new self(); $active = $data['active'] ?? null; - - if (true === $active) { - $model->active = 'yes'; - } elseif (false === $active) { - $model->active = 'no'; - } else { - $model->active = $active; - } + $model = new self(); + $model->active = 'htmlonly' === $active ? $active : ($active ? 'yes' : 'no'); return $model; } diff --git a/src/Model/Domain/OpenTracking.php b/src/Model/Domain/OpenTracking.php index 9c67e6e..d0b6288 100644 --- a/src/Model/Domain/OpenTracking.php +++ b/src/Model/Domain/OpenTracking.php @@ -22,16 +22,9 @@ final class OpenTracking public static function create(array $data): self { - $model = new self(); $active = $data['active'] ?? null; - - if (true === $active) { - $model->active = 'yes'; - } elseif (false === $active) { - $model->active = 'no'; - } else { - $model->active = $active; - } + $model = new self(); + $model->active = $active ? 'yes' : 'no'; return $model; } diff --git a/src/Model/Domain/UnsubscribeTracking.php b/src/Model/Domain/UnsubscribeTracking.php index 2b9ead7..c0e59eb 100644 --- a/src/Model/Domain/UnsubscribeTracking.php +++ b/src/Model/Domain/UnsubscribeTracking.php @@ -25,7 +25,7 @@ final class UnsubscribeTracking public static function create(array $data): self { $model = new self(); - $model->active = ($data['active'] ?? null) ? 'true' : 'false'; + $model->active = ($data['active'] ?? null) ? 'yes' : 'no'; $model->htmlFooter = $data['html_footer'] ?? ''; $model->textFooter = $data['text_footer'] ?? ''; @@ -38,7 +38,7 @@ final class UnsubscribeTracking public function isActive(): bool { - return 'true' === $this->getActive(); + return 'yes' === $this->getActive(); } public function getActive(): string diff --git a/tests/Model/Domain/TrackingResponseTest.php b/tests/Model/Domain/TrackingResponseTest.php index 5b916d8..46d66fd 100644 --- a/tests/Model/Domain/TrackingResponseTest.php +++ b/tests/Model/Domain/TrackingResponseTest.php @@ -29,7 +29,7 @@ class TrackingResponseTest extends BaseModelTest "active": "htmlonly" }, "open": { - "active": "no" + "active": false }, "unsubscribe": { "active": false, @@ -53,7 +53,7 @@ JSON; $this->assertNotEmpty($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->assertEquals('Test', $model->getUnsubscribe()->getHtmlFooter()); $this->assertEquals('Test', $model->getUnsubscribe()->getTextFooter()); diff --git a/tests/Model/Domain/UpdateOpenTrackingResponseTest.php b/tests/Model/Domain/UpdateOpenTrackingResponseTest.php index 9fbdd6a..5dd8668 100644 --- a/tests/Model/Domain/UpdateOpenTrackingResponseTest.php +++ b/tests/Model/Domain/UpdateOpenTrackingResponseTest.php @@ -23,7 +23,7 @@ class UpdateOpenTrackingResponseTest extends BaseModelTest <<<'JSON' { "open": { - "active": "no" + "active": false }, "message": "Domain tracking settings have been updated" }