← All changes
|
includes/abilities/settings/class-get-email-report-settings.php
+21
-8
2.7.0
→
2.9.0
View file →
| @@ -19,10 +19,11 @@ | ||
| 19 | 19 | /** |
| 20 | 20 | * Retrieves ThinkRank Email Reporting settings. |
| 21 | 21 | * |
| 22 | 22 | * Mirrors `GET /thinkrank/v1/email-report/config`: returns the resolved report |
| 23 | - * config (on/off, frequency, recipients, enabled sections), the next scheduled | |
| 24 | - * run and the section catalog. Read-only. | |
| 23 | + * config (on/off, frequency, recipients, enabled sections, why the last | |
| 24 | + * scheduled run sent nothing), the next scheduled run, the section catalog | |
| 25 | + * and the readiness of the data sources. Read-only. | |
| 25 | 26 | */ |
| 26 | 27 | class Get_Email_Report_Settings extends Ability_Base { |
| 27 | 28 | /** |
| 28 | 29 | * Constructor. |
| @@ -29,9 +30,9 @@ | ||
| 29 | 30 | */ |
| 30 | 31 | public function __construct() { |
| 31 | 32 | $this->id = 'thinkrank/get-email-report-settings'; |
| 32 | 33 | $this->label = __( 'Get ThinkRank Email Report Settings', 'thinkrank' ); |
| 33 | - $this->description = __( 'Retrieve ThinkRank Email Reporting settings: whether the scheduled SEO report is on, how often it is sent (days), who receives it, which sections it includes, the next scheduled send, and the section catalog. Use update-email-report-settings to switch it on or off, and send-email-report-test to send one now.', 'thinkrank' ); | |
| 34 | + $this->description = __( 'Retrieve ThinkRank Email Reporting settings: whether the scheduled SEO report is on, how often it is sent (days), who receives it, which sections it includes, the next scheduled send, the section catalog, and readiness — whether Google Search Console is connected (required; scheduled reports are paused and config.last_skip says why while it is not), and whether Google Analytics 4 and AI-assistant traffic data are available to add their sections. Use update-email-report-settings to switch it on or off, and send-email-report-test to send one now.', 'thinkrank' ); | |
| 34 | 35 | } |
| 35 | 36 | |
| 36 | 37 | /** |
| 37 | 38 | * {@inheritDoc} |
| @@ -69,13 +70,24 @@ | ||
| 69 | 70 | public function get_output_schema() { |
| 70 | 71 | return [ |
| 71 | 72 | 'type' => 'object', |
| 72 | 73 | 'properties' => [ |
| 73 | - 'config' => [ | |
| 74 | + 'config' => [ | |
| 74 | 75 | 'type' => 'object', |
| 75 | - 'description' => __( 'The resolved Email Reporting config: enabled, frequency_days, recipients, sections_enabled and the schedule timestamps.', 'thinkrank' ), | |
| 76 | + 'description' => __( 'The resolved Email Reporting config: enabled, frequency_days, recipients, sections_enabled, the schedule timestamps, and last_skip ({reason, at} or null) — why the last scheduled run sent nothing: search_console_not_connected or no_data.', 'thinkrank' ), | |
| 76 | 77 | 'additionalProperties' => true, |
| 77 | 78 | ], |
| 79 | + 'readiness' => [ | |
| 80 | + 'type' => 'object', | |
| 81 | + 'description' => __( 'Data-source readiness: ready (bool — a report can be built), search_console (bool, required), analytics (bool — Google Analytics 4 connected, adds the site-traffic section), ai_traffic (bool — AI-assistant referrals recorded, adds that section), reason (string|null — search_console_not_connected when not ready).', 'thinkrank' ), | |
| 82 | + 'properties' => [ | |
| 83 | + 'ready' => [ 'type' => 'boolean' ], | |
| 84 | + 'search_console' => [ 'type' => 'boolean' ], | |
| 85 | + 'analytics' => [ 'type' => 'boolean' ], | |
| 86 | + 'ai_traffic' => [ 'type' => 'boolean' ], | |
| 87 | + 'reason' => [ 'type' => [ 'string', 'null' ] ], | |
| 88 | + ], | |
| 89 | + ], | |
| 78 | 90 | 'next_run' => [ |
| 79 | 91 | 'type' => [ 'string', 'null' ], |
| 80 | 92 | 'description' => __( 'ISO-8601 timestamp of the next scheduled report, or null when disabled.', 'thinkrank' ), |
| 81 | 93 | ], |
| @@ -104,11 +116,12 @@ | ||
| 104 | 116 | ); |
| 105 | 117 | } |
| 106 | 118 | |
| 107 | 119 | return [ |
| 108 | - 'config' => $manager->config()->get(), | |
| 109 | - 'next_run' => $manager->scheduler()->next_run_iso(), | |
| 110 | - 'sections' => $manager->registry()->describe_for_ui(), | |
| 120 | + 'config' => $manager->config()->get(), | |
| 121 | + 'next_run' => $manager->scheduler()->next_run_iso(), | |
| 122 | + 'sections' => $manager->registry()->describe_for_ui(), | |
| 123 | + 'readiness' => $manager->data_provider()->readiness(), | |
| 111 | 124 | ]; |
| 112 | 125 | } |
| 113 | 126 | |
| 114 | 127 | /** |