id = 'thinkrank/get-seo-analytics-data'; $this->label = __( 'Get ThinkRank SEO Analytics Data', 'thinkrank' ); $this->description = __( 'Retrieve the ThinkRank SEO analytics dashboard data. Requires Google Search Console / Analytics to be connected; returns empty data otherwise. get-integrations-status reports whether those are connected.', 'thinkrank' ); } /** * {@inheritDoc} * * @return array */ public function get_annotations() { return [ 'readonly' => true, 'destructive' => false, 'idempotent' => true, 'priority' => 1.0, 'openWorldHint' => false, ]; } /** * {@inheritDoc} * * @return array */ public function get_input_schema() { return [ 'type' => 'object', 'additionalProperties' => false, 'properties' => [ 'date_range' => [ 'type' => 'string', 'description' => __( 'The reporting date range.', 'thinkrank' ), 'enum' => [ '7d', '30d', '90d' ], 'default' => '30d', ], ], ]; } /** * {@inheritDoc} * * @return array */ public function get_output_schema() { return [ 'type' => 'object', 'additionalProperties' => true, 'properties' => self::empty_properties(), ]; } /** * Execute ability. * * @param array $input Ability input payload. * @return array */ public function execute( $input ) { $date_range = isset( $input['date_range'] ) ? (string) $input['date_range'] : '30d'; if ( ! in_array( $date_range, [ '7d', '30d', '90d' ], true ) ) { $date_range = '30d'; } $manager = new Analytics_Manager(); return $manager->get_dashboard_data( $date_range ); } }