<?php

namespace Database\Seeders;

use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
use App\Classes\Modules\Addresses\Processors\CreateAddressFromOldAddressProcessor;
use App\Classes\Modules\Addresses\Services\CreatesAddress;
use App\Classes\Modules\Companies\DataTransferObjects\CompanyConnectionObject;
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
use App\Classes\Modules\Companies\Processors\CreateCompanyModuleProcessor;
use App\Classes\Modules\Companies\Processors\CreateCompanyProcessor;
use App\Classes\Modules\Companies\Services\ApprovesCompanyConnection;
use App\Classes\Modules\Companies\Services\CreatesCompany;
use App\Classes\Modules\Companies\Services\CreatesCompanyConnection;
use App\Classes\Modules\Companies\Services\UpdatesCompanyStatus;
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
use App\Classes\Modules\Contacts\Services\CreatesContact;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\CompanyType;
use App\Classes\ValueObjects\Constants\BusinessType;

use App\Models\CompanyModule;
use App\Models\OldCompany;
use Illuminate\Database\Seeder;

use App\Models\Company;

class ModernWarehouseTableSeeder extends Seeder
{

    /** @var CreateCompanyProcessor */
    private $createCompanyProcessor;

    /** @var UpdatesCompanyStatus*/
    private $updatesCompanyStatus;

    /** @var CreateCompanyModuleProcessor */
    private $createCompanyModuleProcessor;

    /** @var CreateContactProcessor */
    private $createContactProcessor;

    /** @var CreatesCompanyConnection */
    private $createsCompanyConnection;

    /** @var ApprovesCompanyConnection */
    private $approvesCompanyConnection;

    /** @var CreateAddressFromOldAddressProcessor */
    private $createAddressFromOldAddressProcessor;

    /** @var CreatesAddress */
    private $createsAddress;

    /** @var CreatesCompany */
    private $createsCompany;

    /** @var CreatesContact */
    private $createsContact;

    /**
     * CompaniesTableSeeder constructor.
     * @param CreateCompanyProcessor $createCompanyProcessor
     * @param UpdatesCompanyStatus $updatesCompanyStatus
     * @param CreateCompanyModuleProcessor $createCompanyModuleProcessor
     * @param CreateContactProcessor $createContactProcessor
     * @param CreatesCompanyConnection $createsCompanyConnection
     * @param ApprovesCompanyConnection $approvesCompanyConnection
     * @param CreateAddressFromOldAddressProcessor $createAddressFromOldAddressProcessor
     * @param CreatesAddress $createsAddress
     * @param CreatesCompany $createsCompany
     * @param CreatesContact $createsContact
     */
    public function __construct(CreateCompanyProcessor $createCompanyProcessor, UpdatesCompanyStatus $updatesCompanyStatus, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, CreateAddressFromOldAddressProcessor $createAddressFromOldAddressProcessor, CreatesAddress $createsAddress, CreatesCompany $createsCompany, CreatesContact $createsContact)
    {
        $this->createCompanyProcessor = $createCompanyProcessor;
        $this->updatesCompanyStatus = $updatesCompanyStatus;
        $this->createCompanyModuleProcessor = $createCompanyModuleProcessor;
        $this->createContactProcessor = $createContactProcessor;
        $this->createsCompanyConnection = $createsCompanyConnection;
        $this->approvesCompanyConnection = $approvesCompanyConnection;
        $this->createAddressFromOldAddressProcessor = $createAddressFromOldAddressProcessor;
        $this->createsAddress = $createsAddress;
        $this->createsCompany = $createsCompany;
        $this->createsContact = $createsContact;
    }


    /**
     * Run the database seeds.
     *
     * @return void
     * @throws \App\Classes\Exceptions\AccessForbiddenException
     * @throws \App\Classes\Exceptions\MalformedRequestException
     * @throws \App\Classes\Exceptions\RequestValidationException
     */
    public function run()
    {

        /** @var Company $company */
        $company = $this->createsCompany->execute(new CompanyObject('Modern', 'MODERN', CompanyType::COMPANY_BUSINESS, ApprovalStatus::APPROVED));

        /** @var CompanyModule $companyModule */
        $this->createCompanyModuleProcessor->execute($company, BusinessType::FREIGHT_FORWARDER);

        $companyModule = $this->createCompanyModuleProcessor->execute($company, BusinessType::WAREHOUSE);

        $companyModule->update(['name' => 'Guangzhou', 'reference' => 'GZ-V02']);
        $address = new AddressObject('白云区 白云湖街道 大朗北路 大朗生活区 523A', '(公交车总站对面)', 2, 35, 633, 510000);
        
        $contact = new ContactObject('郑学钟', '18665696389', '', '');
        $this->createsAddress->execute($companyModule, $address);
        $this->createsContact->execute($companyModule, $contact);

        $companyModule = $this->createCompanyModuleProcessor->execute($company, BusinessType::WAREHOUSE);
        $companyModule->update(['name' => 'Klang', 'reference' => 'KL-V02']);


    }

}
