<?php
/**
 * Matador /  REST API / "Sync" Endpoint Schema
 *
 * @link        https://matadorjobs.com/
 * @since       3.8.0
 *
 * @package     Matador Jobs Board
 * @subpackage  Rest
 * @author      Matador Software LLC, Jeremy Scott, Paul Bearne
 * @copyright   (c) 2022, Matador Software, LLC
 *
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
 */

namespace matador\MatadorJobs\Rest\Schema;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Sync Endpoint Schema
 *
 * @since 3.9.0
 *
 * @final
 */
final class SubmissionScreening extends SchemaAbstract {

	/**
	 * Index
	 *
	 * Schema for GET calls to `application/screening`
	 *
	 * @uses https://developer.wordpress.org/reference/functions/absint/
	 * @uses https://developer.wordpress.org/reference/functions/sanitize_title/
	 *
	 * @since 3.8.0
	 *
	 * @return array
	 *
	 * @noinspection PhpArrayShapeAttributeCanBeAddedInspection
	 */
	public static function index(): array {
		return [
			'id'       => [
				'description'       => __( 'The WordPress Post ID for the Matador Jobs Application (Submission) Post to have submission screening actions taken on it.', 'matador-jobs' ),
				'type'              => 'integer',
				'sanitize_callback' => 'absint',
				'required'          => true,
			],
			'hash'     => [
				'description'       => __( 'The security hash for the Submission Post. Used to validate the action is from a valid user.', 'matador-jobs' ),
				'type'              => 'string',
				'sanitize_callback' => 'sanitize_title',
				'required'          => true,
			],
			'action'   => [
				'description' => __( 'The submission screening action to apply.', 'matador-jobs' ),
				'type'        => 'string',
				'sanitize_callback' => 'sanitize_text_field',
				'validate_callback' => function( $value ) {
					return in_array( $value, [ 'add', 'apply', 'delete', 'reset' ], true );
				},
				'required'    => true,
			],
			'url' => [
				'description' => __( 'The URL to redirect the user to.', 'matador-jobs' ),
				'type' => 'string',
				'format' => 'uri',
				'sanitize_callback' => 'esc_url_raw',
			],
		];
	}
}