<?php

namespace Fifa\ConnectId\Sdk\ApiModelValidation;

use Fifa\ConnectId\Sdk\Api\Model\OrganisationLocalType;
use Fifa\ConnectId\Sdk\Registration\ValidationException;
use Fifa\ConnectId\Sdk\Util\Data\ISO3166CountryCode;
use Fifa\ConnectId\Sdk\Util\Data\ISO6392LanguageCode;
use Fifa\ConnectId\Sdk\Util\Data\Organisation\OrganisationNature;
use Fifa\ConnectId\Sdk\Util\Data\ClubTrainingCategory;
use Fifa\ConnectId\Sdk\Util\Data\Status;

class OrganisationLocalTypeValidator
{
    /**
     * Method that validates object provided and throws exception when object's properties are invalid
     *
     * @param OrganisationLocalType|null $validationSubject
     * @param string $validationSubjectName
     * @return void
     * @throws ValidationException
     */
    public static function validate(?OrganisationLocalType $validationSubject, string $validationSubjectName)
    {
        $validationSubjectName = ApiModelValidator::resolveValidationSubjectName($validationSubject, $validationSubjectName);

        ApiModelValidator::cannotBeNull($validationSubject, $validationSubjectName);
        ApiModelValidator::cannotBeNullOrWhitespace($validationSubject->getInternationalName(), $validationSubjectName.".internationalName");
        ApiModelValidator::cannotBeNullOrWhitespace($validationSubject->getLocalName(), $validationSubjectName.".localName");

        ApiModelValidator::validateAllowNull($validationSubject->getOrganisationFIFAId(), FifaIdValidator::class, $validationSubjectName.".organisationFIFAId");
        ApiModelValidator::validateAllowNull($validationSubject->getParentOrganisationFIFAId(), FifaIdValidator::class, $validationSubjectName.".parentOrganisationFIFAId");

        ApiModelValidator::mustMatchEnumValue($validationSubject->getStatus(), Status::getStatuses(), $validationSubjectName.".status");
        $ignoreCase = false;
        ApiModelValidator::mustMatchEnumValue($validationSubject->getLocalLanguage(), XsdSchemaValuesResolver::getValues(ISO6392LanguageCode::class), $validationSubjectName.".localLanguage", $ignoreCase);
        ApiModelValidator::mustMatchEnumValue($validationSubject->getLocalCountry(), XsdSchemaValuesResolver::getValues(ISO3166CountryCode::class), $validationSubjectName.".localCountry", $ignoreCase);
        ApiModelValidator::mustMatchEnumValue($validationSubject->getOrganisationNature(), OrganisationNature::getOrganisationNatures(), $validationSubjectName.".organisationNature");

        ContextTypeValidator::validate($validationSubject->getOfficialAddress(), $validationSubjectName.".officialAddress");

        ApiModelValidator::validateAllowNull($validationSubject->getWebAddress(), WebAddressValidator::class, $validationSubjectName.".webAddress");
        ApiModelValidator::validateAllowNull($validationSubject->getEmail(), EmailValidator::class, $validationSubjectName.".email");
        ApiModelValidator::validateAllowNull($validationSubject->getLogo(), PictureTypeValidator::class, $validationSubjectName.".logo");

        ApiModelValidator::validateAllInCollectionAllowNull($validationSubject->getNationalIdentifier(), NationalIdentifierTypeValidator::class, $validationSubjectName.".nationalIdentifier");
        ApiModelValidator::validateAllInCollectionAllowNull($validationSubject->getLocalOrganisationName(), LocalNameTypeValidator::class, $validationSubjectName.".localOrganisationName");
        ApiModelValidator::validateAllInCollectionAllowNull($validationSubject->getSupportedDiscipline(), SupportedDisciplineTypeValidator::class, $validationSubjectName.".supportedDiscipline");

        ApiModelValidator::mustBeNullOrMatchEnumValue($validationSubject->getClubTrainingCategory(), ClubTrainingCategory::getClubTrainingCategories(), $validationSubjectName.".clubTrainingCategory");
        ApiModelValidator::validateAllowNull($validationSubject->getComplianceAndPaymentManager(), ComplianceAndPaymentManagerTypeValidator::class, $validationSubjectName.".complianceAndPaymentManager");
    }
}