array( 'type' => 'string', 'enum' => Entitlement_Repository::OUTPUT_ACTIONS, 'description' => __( 'Whether to store or remove an output.', 'acrossai-abilities-manager' ), ), 'data' => array( 'type' => 'object', 'description' => __( 'The output to save, or an identifier for the one to delete.', 'acrossai-abilities-manager' ), 'additionalProperties' => true, ), ); } protected function output_properties(): array { return array( 'action' => array( 'type' => 'string' ) ); } protected function required_input(): array { return array( 'action', 'data' ); } protected function annotations(): array { return array( 'readonly' => false, 'destructive' => false, 'idempotent' => true ); } /** * @param array $input * @return array|WP_Error */ protected function run( array $input ) { if ( ! isset( $input['data'] ) || ! is_array( $input['data'] ) ) { return new WP_Error( 'invalid_input', __( 'data must be an object.', 'acrossai-abilities-manager' ) ); } $result = Entitlement_Repository::manage_output( isset( $input['action'] ) ? sanitize_key( (string) $input['action'] ) : '', $input['data'] ); if ( is_wp_error( $result ) ) { return $result; } $result['message'] = 'save' === $result['action'] ? __( 'Stored the Content AI output.', 'acrossai-abilities-manager' ) : __( 'Deleted the Content AI output.', 'acrossai-abilities-manager' ); return $result; } }