<?php
/**
 * API Service Provider
 *
 * Registers API controllers in the container
 *
 * @package NemtlyBooking
 * @since   PBOOKING_SINCE
 */

namespace NemtlyBooking\Providers;

use NemtlyBooking\Core\Service_Provider;
use NemtlyBooking\Core\Container;
use NemtlyBooking\API\Events_Controller;
use NemtlyBooking\API\Booking_Controller;
use NemtlyBooking\API\Settings_Controller;
use NemtlyBooking\API\Admin_Controller;
use NemtlyBooking\API\Setup_Controller;
use NemtlyBooking\API\Payment_Controller;
use NemtlyBooking\API\Google_Auth_Controller;
use NemtlyBooking\Integrations\Google\Google_OAuth_Provider;

/**
 * API Service Provider class
 *
 * @since PBOOKING_SINCE
 */
class API_Service_Provider extends Service_Provider {

    /**
     * Register API controllers
     *
     * @since PBOOKING_SINCE
     *
     * @param Container $container The dependency injection container.
     */
    public function register( Container $container ) {
        // Events Controller
        $container->register(
            'events_controller',
            function ( $container ) {
                return new Events_Controller( $container );
            }
        );

        // Booking Controller
        $container->register(
            'booking_controller',
            function ( $container ) {
                return new Booking_Controller( $container );
            }
        );

        // Settings Controller
        $container->register(
            'settings_controller',
            function () {
                return new Settings_Controller();
            }
        );

        // Admin Controller
        $container->register(
            'admin_controller',
            function ( $container ) {
                return new Admin_Controller( $container );
            }
        );

        // Setup Controller
        $container->register(
            'setup_controller',
            function () {
                return new Setup_Controller();
            }
        );

        // Payment Controller
        $container->register(
            'payment_controller',
            function ( $container ) {
                return new Payment_Controller(
                    $container->get( 'payment_repository' ),
                    $container->get( 'booking_repository' )
                );
            }
        );

        // Google Auth Controller
        $container->register(
            'google_auth_controller',
            function () {
                return new Google_Auth_Controller( new Google_OAuth_Provider() );
            }
        );

        $this->mark_registered();
    }

    /**
     * Boot API controllers
     *
     * @since PBOOKING_SINCE
     *
     * @param Container $container The dependency injection container.
     */
    public function boot( Container $container ) {
        // Boot any controllers that need initialization
    }
}
