*/ protected function input_properties(): array { return array( 'library_id' => array( 'type' => 'integer', 'description' => __( 'Library snippet id, from search-library.', 'acrossai-abilities-manager' ), ), ); } /** * @since 0.0.34 * @return array */ protected function required_input(): array { return array( 'library_id' ); } /** * @since 0.0.34 * @return array */ protected function output_properties(): array { return array( 'snippet' => array( 'type' => 'object', 'additionalProperties' => true ), ); } /** * @since 0.0.34 * @return array */ protected function annotations(): array { return array( 'readonly' => true, 'destructive' => false, 'idempotent' => true ); } /** * @since 0.0.34 * @param array $input Input. * @return array|WP_Error */ protected function run( array $input ) { $snippet = Library_Repository::find( (int) ( $input['library_id'] ?? 0 ) ); if ( is_wp_error( $snippet ) ) { return $snippet; } return array( 'snippet' => $snippet ); } }