<?php

namespace Shm\ShmPayment\TBankPayment\TBankCollections;

use Shm\Collection\Collection;
use Shm\Shm;
use Shm\ShmTypes\StructureType;

class TNominalBeneficiaries extends Collection
{


    public function schema(): StructureType
    {
        return Shm::structure([

            "type" => Shm::enum([
                'IP_RESIDENT' => "ИП",
                'UL_RESIDENT' => "Юр.лицо",
            ]),

            "ipResident" => Shm::structure([
                "type" => Shm::static("IP_RESIDENT"),
                "firstName" => Shm::string()->title("Имя"),
                "middleName" => Shm::string()->title("Отчество"),
                "lastName" => Shm::string()->title("Фамилия"),
                "birthDate" => Shm::string()->title("Дата рождения в формате YYYY-MM-DD"),
                "birthPlace" => Shm::string()->title("Место рождения"),
                "citizenship" => Shm::string()->title("Гражданство"),
                "phoneNumber" => Shm::string()->title("Телефон"),
                "email" => Shm::string()->title("Email"),
                "passport" => Shm::structure([
                    "serial" => Shm::string()->title("Серия"),
                    "number" => Shm::string()->title("Номер"),
                    "date" => Shm::string()->title("Дата выдачи"),
                    "organization" => Shm::string()->title("Кем выдан"),
                    "divisionCode" => Shm::string()->title("Код подразделения"),
                ]),
                "registrationDate" => Shm::string()->title("Дата регистрации ИП в формате YYYY-MM-DD"),
                "registrationAddress" => Shm::string()->title("Адрес регистрации"),
                'inn' => Shm::string()->title("ИНН"),
                "snils" => Shm::string()->title("СНИЛС"),
            ])->cond(Shm::cond()->equals("type", "IP_RESIDENT"))->title("ИП"),
            "ulResident" => Shm::structure([
                "type" => Shm::static("UL_RESIDENT"),
                "name" => Shm::string()->title("Наименование юридического лица"),
                "phoneNumber" => Shm::string()->title("Телефон"),
                "email" => Shm::string()->title("Email"),

                //LEGAL_ENTITY_ADDRESS
                "legalEntityAddress" => Shm::string()->title("Адрес юридического лица"),
                //POSTAL_ADDRESS
                "postalAddress" => Shm::string()->title("Почтовый адрес"),
                'registrationDate' => Shm::string()->title("Дата регистрации юридического лица в формате YYYY-MM-DD"),
                'opf' => Shm::enum([
                    "АО" => "Акционерное общество",
                    "ООО" => "Общество с ограниченной ответственностью",
                    "ПАО" => "Публичное акционерное общество",

                ])->title("Тип юридического лица"),
                "inn" => Shm::string()->title("ИНН"),
                "ogrn" => Shm::string()->title("ОГРН"),
            ])->cond(Shm::cond()->equals("type", "UL_RESIDENT"))->title("Юр.лицо"),

            'scoring' => Shm::structure([
                "status" => Shm::enum([
                    'FAILED' => 'Отклонен',
                    'SUCCESS' => 'Одобрен',
                    'PENDING' => 'Ожидает проверки',
                ])->title("Проверка в финансовом мониторинге"),
                "warnings" => Shm::arrayOf(Shm::structure([
                    "code" => Shm::string()->title("Код предупреждения"),
                    "description" => Shm::string()->title("Описание предупреждения"),
                ]))->title("Предупреждения"),
                "errors" => Shm::arrayOf(Shm::structure([
                    "code" => Shm::string()->title("Код ошибки"),
                    "description" => Shm::string()->title("Описание ошибки"),
                ]))->title("Ошибки"),
            ])->title("Проверка в финансовом мониторинге"),

        ]);
    }
}