id = 'sureforms/get-entry'; $this->label = __( 'Get Entry Details', 'sureforms' ); $this->description = __( 'Retrieve detailed information about a specific SureForms form submission entry, including all submitted field data with labels.', 'sureforms' ); $this->capability = 'manage_options'; } /** * {@inheritDoc} * * @since 2.5.2 */ public function get_annotations() { return [ 'readonly' => true, 'destructive' => false, 'idempotent' => true, 'priority' => 1.0, 'openWorldHint' => false, ]; } /** * {@inheritDoc} * * @since 2.5.2 */ public function get_input_schema() { return [ 'type' => 'object', 'additionalProperties' => false, 'properties' => [ 'entry_id' => [ 'type' => 'integer', 'description' => __( 'The ID of the entry to retrieve.', 'sureforms' ), ], ], 'required' => [ 'entry_id' ], ]; } /** * {@inheritDoc} * * @since 2.5.2 */ public function get_output_schema() { return [ 'type' => 'object', 'properties' => [ 'id' => [ 'type' => 'integer' ], 'form_id' => [ 'type' => 'integer' ], 'form_name' => [ 'type' => 'string' ], 'status' => [ 'type' => 'string' ], 'created_at' => [ 'type' => 'string' ], 'form_data' => [ 'type' => 'array', 'items' => [ 'type' => 'object', 'properties' => [ 'label' => [ 'type' => 'string' ], 'value' => [], 'block_name' => [ 'type' => 'string' ], ], ], ], 'submission_info' => [ 'type' => 'object' ], 'user' => [ 'type' => [ 'object', 'null' ] ], ], ]; } /** * Execute the get-entry ability. * * @param array $input Validated input data. * @since 2.5.2 * @return array|\WP_Error */ public function execute( $input ) { $entry_id = Helper::get_integer_value( $input['entry_id'] ?? 0 ); $entry = EntriesTable::get( $entry_id ); if ( empty( $entry ) ) { return new \WP_Error( 'srfm_entry_not_found', __( 'Entry not found.', 'sureforms' ), [ 'status' => 404 ] ); } $parsed = $this->parse_entry( $entry ); return array_merge( [ 'id' => $entry_id ], $parsed ); } }