| @@ -3,12 +3,13 @@ | ||
| 3 | 3 | declare(strict_types=1); |
| 4 | 4 | |
| 5 | 5 | namespace Metricool\Http\Endpoints; |
| 6 | 6 | |
| 7 | -use GuzzleHttp\Exception\GuzzleException; | |
| 7 | +use Metricool\Vendor\GuzzleHttp\Exception\GuzzleException; | |
| 8 | 8 | use Metricool\Http\Endpoints\Responses\ConnectedNetworksResponse; |
| 9 | 9 | use Metricool\Http\Metricool\MetricoolApi; |
| 10 | 10 | use Metricool\Interfaces\SingleEndpointInterface; |
| 11 | +use Metricool\Services\DashboardService; | |
| 11 | 12 | use Metricool\Traits\HasAllowlistControl; |
| 12 | 13 | use Metricool\Traits\HasRestAccess; |
| 13 | 14 | |
| 14 | 15 | class ConnectedNetworksEndpoint implements SingleEndpointInterface |
| @@ -18,12 +19,14 @@ | ||
| 18 | 19 | |
| 19 | 20 | public const ROUTE = 'connected_networks'; |
| 20 | 21 | |
| 21 | 22 | public MetricoolApi $metricoolApi; |
| 23 | + public DashboardService $dashboard; | |
| 22 | 24 | |
| 23 | - public function __construct(MetricoolApi $metricoolApi) | |
| 25 | + public function __construct(MetricoolApi $metricoolApi, DashboardService $dashboard) | |
| 24 | 26 | { |
| 25 | 27 | $this->metricoolApi = $metricoolApi; |
| 28 | + $this->dashboard = $dashboard; | |
| 26 | 29 | } |
| 27 | 30 | |
| 28 | 31 | /** |
| 29 | 32 | * @inheritDoc |
| @@ -33,13 +36,13 @@ | ||
| 33 | 36 | return self::ROUTE; |
| 34 | 37 | } |
| 35 | 38 | |
| 36 | 39 | /** |
| 37 | - * @inheritDoc | |
| 40 | + * Only enable this endpoint when onboarding is completed | |
| 38 | 41 | */ |
| 39 | 42 | public function enabled(): bool |
| 40 | 43 | { |
| 41 | - return $this->adminAccessAllowed(); | |
| 44 | + return $this->dashboard->isOnboardingCompleted(); | |
| 42 | 45 | } |
| 43 | 46 | |
| 44 | 47 | /** |
| 45 | 48 | * @inheritDoc |
| @@ -54,8 +57,10 @@ | ||
| 54 | 57 | } |
| 55 | 58 | |
| 56 | 59 | /** |
| 57 | 60 | * Return the brands related to the user |
| 61 | + * | |
| 62 | + * GET /wp-json/metricool/v1/connected_networks | |
| 58 | 63 | */ |
| 59 | 64 | public function callback(\WP_REST_Request $request): \WP_REST_Response |
| 60 | 65 | { |
| 61 | 66 | try { |