\WP_REST_Server::READABLE, 'callback' => array( $this, 'properties' ), 'permission_callback' => array( $this, 'can_manage' ), 'args' => array(), ) ); register_rest_route( self::REST_NAMESPACE, '/admin/streams', array( 'methods' => \WP_REST_Server::READABLE, 'callback' => array( $this, 'streams' ), 'permission_callback' => array( $this, 'can_manage' ), 'args' => array( 'property' => self::arg( array( 'type' => 'string', 'pattern' => '^properties/[0-9]+$', 'required' => true, ) ), ), ) ); register_rest_route( self::REST_NAMESPACE, '/admin/gsc-sites', array( 'methods' => \WP_REST_Server::READABLE, 'callback' => array( $this, 'gsc_sites' ), 'permission_callback' => array( $this, 'can_manage' ), 'args' => array(), ) ); } /** * GET /admin/properties → {data: account summaries}. * * @return \WP_REST_Response|\WP_Error */ public function properties() { try { return new \WP_REST_Response( array( 'data' => $this->plugin->admin_api()->account_summaries() ) ); } catch ( ApiError $e ) { return self::error( $e ); } } /** * GET /admin/streams?property= → {data: web streams}. * * @param \WP_REST_Request $request Request. * @return \WP_REST_Response|\WP_Error */ public function streams( \WP_REST_Request $request ) { try { return new \WP_REST_Response( array( 'data' => $this->plugin->admin_api()->web_streams( (string) $request->get_param( 'property' ) ) ) ); } catch ( ApiError $e ) { return self::error( $e ); } } /** * GET /admin/gsc-sites → {data: sites}. * * @return \WP_REST_Response|\WP_Error */ public function gsc_sites() { try { return new \WP_REST_Response( array( 'data' => $this->plugin->search_console()->sites() ) ); } catch ( ApiError $e ) { return self::error( $e ); } } }