<?php

/**
 * This file is part of the bitrix24-php-sdk package.
 *
 * © Vadim Soluyanov <vadimsallee@gmail.com>
 *
 * For the full copyright and license information, please view the MIT-LICENSE.txt
 * file that was distributed with this source code.
 */

declare(strict_types=1);

namespace Bitrix24\SDK\Services\Department;

use Bitrix24\SDK\Attributes\ApiServiceBuilderMetadata;
use Bitrix24\SDK\Core\Credentials\Scope;
use Bitrix24\SDK\Services\AbstractServiceBuilder;
use Bitrix24\SDK\Services\Department;

#[ApiServiceBuilderMetadata(new Scope(['department']))]
class DepartmentServiceBuilder extends AbstractServiceBuilder
{
    public function department(): Department\Service\Department
    {
        if (!isset($this->serviceCache[__METHOD__])) {
            $batch = new Department\Batch(
                $this->core,
                $this->log
            );
            $this->serviceCache[__METHOD__] = new Department\Service\Department(
                new Department\Service\Batch($batch, $this->log),
                $this->core,
                $this->log
            );
        }

        return $this->serviceCache[__METHOD__];
    }
}
