Skip to content

Union

Helper to add into your Union product to help you with common scenarios/problems

Interface

Use

In your class definition add , UnionInterface after implements GeneralProductInterface
and in your section of uses (at the top) add

use BP\Products\Interfaces\UnionInterface;

Constants

// Car region
public const BRATISLAVA = 'BA';
public const BAN_BYST = 'BB';
public const KOSICE = 'KE';
public const NITRA = 'NI';
public const PRESOV = 'PO';
public const TRNAVA = 'TA';
public const TRENCIN = 'TC';
public const ZILINA = 'ZA';

Trait

Use

Right below your class definition add

use BP\Products\Traits\UnionTrait;

Methods

brokerData(bool $sendMailToBroker = false): array

/**
 * Helper to generate broker data for api calls
 *
 * @param bool $sendMailToBroker
 * @return array
 */

// Example
$requestData = [
    ...
    'broker' => $this->brokerData()
    ...
];

checkCommonValidations(): array

/**
 * Check is valid for Union together (checking type, fuel, clientage, brand, model)
 *
 * @return array
 */

// Example
public function isValid()
{
   // Custom validations here
   // ...

   $this->checkCommonValidations();
}

sendEmail2Insurer(): bool

/**
 * Detect if should send email from insurance company to client
 * Value for sendEmail2Insurer param
 *
 * @return bool
 */

// Example
$data = [
   // ...
   'sendEmail2Insurer' => $this->sendEmail2Insurer(),
   // ...
];


Parsers

Predefined parsers so you only call $this->value('field'); for these parsers and they will be parsed into right format
Don't redefine them if you doesn't need different outputs

Automatically parsed fields

  • [Field::BLOCK_HOLDER, Field::LEGAL_FORM] (parseHolderLegalForm)
    LEGAL_FORM_FO => 'FON',
    LEGAL_FORM_SE => 'FOP',
    LEGAL_FORM_COM => 'PO'
    
  • [Field::BLOCK_HOLDER, Field::BIRTH] (parseHolderBirth)
    Returns only year
    
  • Field::VEHICLE_BRAND
    returns array in format ['code' => 'codevalue', 'text' => 'textvalue]
    
  • Field::VEHICLE_MODEL
    returns array in format ['code' => 'codevalue', 'text' => 'textvalue]
    
  • Field::PAYMENT_FREQUENCY
    FREQUENCY_YEAR => 'YEARLY',
    FREQUENCY_HALF => 'SEMI_ANNUALLY',
    FREQUENCY_QUARTER => 'QUARTERLY'
    
  • Field::VEHICLE_REGION
    for example all codes from Bratislava (BA, BL,...) converts to Only BA, see
    
  • Field::COLOR
    converts to text value
    
  • Field::FUEL
    FUEL_PETROL => 'GASOLINE',
    FUEL_DIESEL => 'DIESEL',
    FUEL_ELECTRIC => 'ELECTRIC_ENGINE',
    FUEL_GAS_PETROL => 'GASOLINE_LPG',
    FUEL_HYB_PETROL => 'GASOLINE_ELECTRIC_ENGINE',
    FUEL_NO => '',
    // Said by Union that its ok
    FUEL_LPG => $isKasko ? 'GASOLINE_LPG' : false,
    FUEL_CNG => $isKasko ? 'GASOLINE_LPG' : false,