<?php
/**
 * Payment Service Provider
 *
 * @package NemtlyBooking
 */

namespace NemtlyBooking\Providers;

use NemtlyBooking\Core\Service_Provider;
use NemtlyBooking\Core\Container;
use NemtlyBooking\Repositories\Payment_Repository;
use NemtlyBooking\Gateways\Stripe_Gateway;
use NemtlyBooking\Services\Payment_Service;
use NemtlyBooking\Services\Booking_Service;

/**
 * Class Payment_Service_Provider
 */
class Payment_Service_Provider extends Service_Provider {
    /**
     * Register services
     *
     * @param Container $container Container.
     */
    public function register( Container $container ) {
        // Payment Repository
        $container->register(
            'payment_repository',
            function () {
                return new Payment_Repository();
            }
        );

        // Stripe Gateway
        $container->register(
            'stripe_gateway',
            function ( $c ) {
                return new Stripe_Gateway(
                    $c->get( 'settings_service' )
                );
            }
        );

        // Payment Service
        $container->register(
            'payment_service',
            function ( $c ) {
                return new Payment_Service(
                    $c->get( 'payment_repository' ),
                    $c->get( 'stripe_gateway' ),
                    $c->get( 'settings_service' ),
                    $c->get( 'booking_service' )
                );
            }
        );

        $this->mark_registered();
    }
}
