diff --git a/lib/API/MP/v1/API.php b/lib/API/MP/v1/API.php index 239fa36ff7..91cb43f661 100644 --- a/lib/API/MP/v1/API.php +++ b/lib/API/MP/v1/API.php @@ -2,6 +2,7 @@ namespace MailPoet\API\MP\v1; +use MailPoet\Config\Changelog; use MailPoet\Models\Segment; use MailPoet\Models\Subscriber; use MailPoet\Models\SubscriberSegment; @@ -21,14 +22,19 @@ class API { /** @var Subscribers */ private $subscribers; + /** @var Changelog */ + private $changelog; + public function __construct( RequiredCustomFieldValidator $requiredCustomFieldValidator, CustomFields $customFields, - Subscribers $subscribers + Subscribers $subscribers, + Changelog $changelog ) { $this->requiredCustomFieldValidator = $requiredCustomFieldValidator; $this->customFields = $customFields; $this->subscribers = $subscribers; + $this->changelog = $changelog; } public function getSubscriberFields() { @@ -223,4 +229,14 @@ class API { } return $subscriber->withCustomFields()->withSubscriptions()->asArray(); } + + public function isSetupComplete() { + return !( + $this->changelog->shouldShowWelcomeWizard() + || $this->changelog->shouldShowWooCommerceListImportPage() + || $this->changelog->shouldShowRevenueTrackingPermissionPage() + || $this->changelog->isMp2MigrationInProgress() + || $this->changelog->shouldShowMp2Migration() + ); + } } diff --git a/tests/integration/API/MP/APITest.php b/tests/integration/API/MP/APITest.php index aefe389ad2..38bf432726 100644 --- a/tests/integration/API/MP/APITest.php +++ b/tests/integration/API/MP/APITest.php @@ -8,6 +8,7 @@ use MailPoet\API\JSON\ResponseBuilders\SubscribersResponseBuilder; use MailPoet\API\MP\v1\API; use MailPoet\API\MP\v1\CustomFields; use MailPoet\API\MP\v1\Subscribers; +use MailPoet\Config\Changelog; use MailPoet\CustomFields\CustomFieldsRepository; use MailPoet\Entities\CustomFieldEntity; use MailPoet\Entities\SegmentEntity; @@ -67,7 +68,8 @@ class APITest extends \MailPoetTest { return new API( $this->diContainer->get(RequiredCustomFieldValidator::class), $this->diContainer->get(CustomFields::class), - $subscriberActions + $subscriberActions, + $this->diContainer->get(Changelog::class) ); } diff --git a/tests/integration/API/MP/SubscribersTest.php b/tests/integration/API/MP/SubscribersTest.php index 4726c595d2..a6ce214ba7 100644 --- a/tests/integration/API/MP/SubscribersTest.php +++ b/tests/integration/API/MP/SubscribersTest.php @@ -8,6 +8,7 @@ use MailPoet\API\JSON\ResponseBuilders\SubscribersResponseBuilder; use MailPoet\API\MP\v1\API; use MailPoet\API\MP\v1\CustomFields; use MailPoet\API\MP\v1\Subscribers; +use MailPoet\Config\Changelog; use MailPoet\Entities\SegmentEntity; use MailPoet\Entities\SubscriberEntity; use MailPoet\Newsletter\Scheduler\WelcomeScheduler; @@ -57,7 +58,8 @@ class SubscribersTest extends \MailPoetTest { return new API( $this->makeEmpty(RequiredCustomFieldValidator::class), $this->diContainer->get(CustomFields::class), - $subscriberActions + $subscriberActions, + $this->diContainer->get(Changelog::class) ); }