<?php

namespace SugarCalendarBookings\Ajax;

use SugarCalendarBookings\Admin\DashboardWidgetController;
use SugarCalendarBookings\Appointments\Admin\AppointmentController;
use SugarCalendarBookings\BookingForm\BookingFormController;
use SugarCalendarBookings\Calendar\Admin\CalendarController;
use SugarCalendarBookings\Customers\Admin\CustomerController;
use SugarCalendarBookings\Locations\Admin\LocationController;
use SugarCalendarBookings\Migration\MigrationController;
use SugarCalendarBookings\Payments\PaymentsController;
use SugarCalendarBookings\Services\Admin\ServiceController;
use SugarCalendarBookings\Admin\Settings\IntegrationsController;
use SugarCalendarBookings\Admin\Settings\SettingsController;
use SugarCalendarBookings\Availability\DateOverridesController;
use SugarCalendarBookings\Support\Ajax\AbstractRoutes;
use SugarCalendarBookings\Support\Tags\Admin\TagsController;

/**
 * Admin AJAX routes.
 *
 * @since 1.0.0
 */
class AdminRoutes extends AbstractRoutes {

	/**
	 * Register the routes.
	 *
	 * @since 1.0.0
	 * @since 1.2.0 Separate tags routes.
	 */
	protected function register() {

		// Services.
		$this->route( 'service_create', [ ServiceController::class, 'create' ] );
		$this->route( 'service_update', [ ServiceController::class, 'update' ] );
		$this->route( 'service_delete', [ ServiceController::class, 'delete' ] );
		$this->route( 'service_get_create_form_data', [ ServiceController::class, 'get_create_form_data' ] );
		$this->route( 'service_get_edit_form_data', [ ServiceController::class, 'get_edit_form_data' ] );
		$this->route( 'service_get_share_data', [ ServiceController::class, 'get_share_data' ] );
		$this->route( 'service_get_booking_form_data', [ BookingFormController::class, 'get_booking_form_data' ] );
		$this->route( 'service_get_services_list_data', [ BookingFormController::class, 'get_services_list_data' ] );

		// Locations.
		$this->route( 'location_create', [ LocationController::class, 'create' ] );
		$this->route( 'location_update', [ LocationController::class, 'update' ] );
		$this->route( 'location_delete', [ LocationController::class, 'delete' ] );
		$this->route( 'location_get_create_form_data', [ LocationController::class, 'get_create_form_data' ] );
		$this->route( 'location_get_edit_form_data', [ LocationController::class, 'get_edit_form_data' ] );

		// Customers.
		$this->route( 'customer_create', [ CustomerController::class, 'create' ] );
		$this->route( 'customer_update', [ CustomerController::class, 'update' ] );
		$this->route( 'customer_delete', [ CustomerController::class, 'delete' ] );
		$this->route( 'customer_get_create_form_data', [ CustomerController::class, 'get_create_form_data' ] );
		$this->route( 'customer_get_edit_form_data', [ CustomerController::class, 'get_edit_form_data' ] );

		// Appointments.
		$this->route( 'appointment_create', [ AppointmentController::class, 'create' ] );
		$this->route( 'appointment_update', [ AppointmentController::class, 'update' ] );
		$this->route( 'appointment_cancel', [ AppointmentController::class, 'cancel' ] );
		$this->route( 'appointment_delete', [ AppointmentController::class, 'delete' ] );
		$this->route( 'appointment_get_create_form_data', [ AppointmentController::class, 'get_create_form_data' ] );
		$this->route( 'appointment_get_edit_form_data', [ AppointmentController::class, 'get_edit_form_data' ] );
		$this->route( 'appointment_navigate_to_position', [ AppointmentController::class, 'navigate_to_position' ] );
		$this->route( 'appointment_resend_notifications', [ AppointmentController::class, 'resend_notifications' ] );

		// Payments.
		$this->route( 'payment_refund', [ PaymentsController::class, 'refund' ] );

		// Tags.
		$this->register_tags_routes();

		// Settings.
		$this->route( 'settings_format_date_time', [ SettingsController::class, 'format_date_time' ] );
		$this->route( 'settings_get_email_defaults', [ SettingsController::class, 'get_email_defaults' ] );

		// Integrations.
		$this->route( 'integrations_delete_connection', [ IntegrationsController::class, 'delete_connection' ] );
		$this->route( 'integrations_refresh_token', [ IntegrationsController::class, 'refresh_token' ] );

		// Date Overrides.
		$this->route( 'date_override_create', [ DateOverridesController::class, 'create' ] );
		$this->route( 'date_override_update', [ DateOverridesController::class, 'update' ] );
		$this->route( 'date_override_delete', [ DateOverridesController::class, 'delete' ] );
		$this->route( 'date_override_get_all', [ DateOverridesController::class, 'get_all' ] );
		$this->route( 'date_override_get_create_form_data', [ DateOverridesController::class, 'get_create_form_data' ] );
		$this->route( 'date_override_get_edit_form_data', [ DateOverridesController::class, 'get_edit_form_data' ] );

		// Migration.
		$this->route( 'migration_migrate_amelia', [ MigrationController::class, 'migrate_amelia' ] );
		$this->route( 'migration_start', [ MigrationController::class, 'start_migration' ] );
		$this->route( 'migration_process_batch', [ MigrationController::class, 'process_batch' ] );
		$this->route( 'migration_get_status', [ MigrationController::class, 'get_status' ] );
		$this->route( 'migration_download_report', [ MigrationController::class, 'download_report' ] );

		// Calendar.
		$this->route( 'calendar_screen_options_update', [ CalendarController::class, 'update_screen_options' ] );
		$this->route( 'calendar_screen_appointment_popover', [ CalendarController::class, 'get_appointment_popover' ] );

		// Dashboard Widget.
		$this->route( 'dashboard_widget_save_hide_recommended_plugin', [ DashboardWidgetController::class, 'save_hide_recommended_plugin' ] );
	}

	/**
	 * Register tags routes.
	 *
	 * @since 1.2.0
	 *
	 * @return void
	 */
	protected function register_tags_routes() {

		$this->route( 'tag_create', [ TagsController::class, 'create' ] );
	}
}
