Skip to content

Allianz

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

There are helpers for: - *New products (Home, Pzp, Kasko) - *Old products (Cp)

Interface

Use

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

use BP\Products\Interfaces\AllianzInterface;

Constants

// Bonus malus (*New product)
self::BM_MALUS_5 *(array)*  // 200192-malus
self::BM_0 *(array)*        // 200191-zaklad
self::BM_BONUS_5 *(array)*  // 200190-bonus

// PZP coverages (*New product)
// self::PZP_COVERAGE_5_1 *(array)*     disabled by insurance company
self::PZP_COVERAGE_524_105 *(array)*
// self::PZP_COVERAGE_5_3 *(array)*>    disabled by insurance company
self::PZP_COVERAGE_6_3 *(array)*
self::PZP_COVERAGE_10_5 *(array)*

// Inspections (*New product)
self::INSPECTION_NOT_NEEDED *(array)*
self::INSPECTION_NEW_VEHICLE *(array)*
self::INSPECTION_OLD_VEHICLE *(array)*

// Discounts (*New product)
self::BUSINESS_DISCOUNT_PZP *(array)*
self::BUSINESS_DISCOUNT_CASCO *(array)*

// Insurance frequencies (*Old product)
self::FREQUENCY_YEAR = 'rocne'
self::FREQUENCY_HALF = 'polrocne'
self::FREQUENCY_QUARTER = 'stvrtrocne'

// Insurance frequencies (*New product)
self::FREQUENCY_YEAR_NEW *(array)*
self::FREQUENCY_HALF_NEW *(array)*
self::FREQUENCY_QUARTER_NEW *(array)*

// Yes / no (*Old product)
self::YES = 'ano'
self::NO = 'nie'

// Date time formats (*New product)
self::DATETIME
self::DATE

// Specials (*New product)
self::SALES_CHANNEL = '4-ma-makleri'
self::ECO2 = false
self::ECO = true

Trait

Use

Right below your class definition add

use BP\Products\Traits\AllianzTrait;

Methods

addressData(\BP\Helper\Address $address, bool $isPlaceOfInsurance = false): array

*New product

/**
 * Generate address block from our address
 *
 * @param Address $address
 * @param bool $isPlaceOfInsurance (true if should add data for place of insurance)
 * @return array
 */

// Required field you have to add:
// Field::STREET, Field::NUMBER_REGISTER, Field::NUMBER_DESCRIPTIVE, Field::ZIP, Field::CITY

// Example
[
    ...
    'address1' => $this->addressData($policyholderData->address),
    ...
]

bonusMonths(): int

*New product

/**
 * Detect number of month for bonus
 *
 * @return int
 */

// Example
$data['policyModel']['calculation']['policy']['insurances'][1]['insuredSubjects'][0]['bonusMonths'] = $this->bonusMonths();

brokerOwnerData(): array

*New product

/**
 * Generate owner (broker) data block
 *
 * @return array
 */

// Example
[
    ...
    'owner' => $this->brokerOwnerData()
    ...
]

callApiWithCheck(string $url, $data, string $method)

*New product

/**
 * Check callApi with response check
 *
 * @param string $url
 * @param array $data (automatically json_encoded)
 * @param string $method
 * @return mixed (false or object) (result is automatically json_decoded)
 */

// Example
    // Call api
    $result = $this->callApiWithCheck('contract', $data, 'post');

    // Check response
    if ($result) {
        // do magic
    }

downloadDocuments(array $uuids = []): bool

*New product

/**
 * Download documents helper
 *
 * @param array $uuids (custom uuids to add to main document)
 * specifiy array of parts of uuid
 * for example if uuid is MA2018_MA_Ipid_Eco, you can pass ['Ipid'] to get it
 * @return boolean
 */

// Example
public function documents()
{
    // Main docs (contract, green card ...)
    return $this->downloadDocuments();

    // With custom docs (where uuid contains "Vinkul")
    return $this->downloadDocuments(['Vinkul']);
}

fixPhone($phone): string

*New product

/**
 * Fix phone to +421 format
 *
 * @param string $phone
 * @return string
 */

// Example
[
    ...
    'owner' => [
        'phone' => $this->fixPhone($policyholder->phone)
        ....
    ]
    ...
]

formatDate(?string $date): string

*Old product

/**
 * Convert date into right format
 *
 * @param string $date
 * @return string
 */

// Example
public function parseDateOfFirstEvidence(string $date): string
{
    return $this->formatDate($date);
}

getCarGroups(): array

*New product

/**
 * Get vehicle car groups
 *
 * @return array
 */

// Return example
[
    "4017" => "SK12",
    "4018" => "SK12",
    "4019" => "SK12",
    "4020" => "SK14",
    "4021" => "SK14",
    "4022" => "SK14",
    "4023" => "SK12",
    "4024" => "SK10",
    "4025" => "SK10"
]

// Example
$carGroups = $this->getCarGroups();

foreach ($data['policyModel']['calculation']['policy']['insurances'][1]['insuredSubjects'][0]['risks'] as &$risk) {
    if (isset($carGroups[substr($risk['id'], 0, 4)])) {
        $risk['carGroup'] = $carGroups[substr($risk['id'], 0, 4)];
    }
}

getVehicleBrandModelData(): array

*New product

/**
 * Get vehicle info data about model/brand
 *
 * @return array
 */

// Example
$data['policyModel']['vehicleInfo'] = array_merge(
    $data['policyModel']['vehicleInfo'],
    $this->getVehicleBrandModelData(),
    [...]
);

npzId()

*New product

/**
 * Get npz id
 *
 * @return int|null
 */

// Example in prices
public function price(array $data, array $frequency)
{
    // Set frequency
    $data['policyModel']['calculation']['policy']['paymentFrequency'] = $frequency;
    if ($npzId = $this->npzId()) {
        $data['npzId'] = $npzId;
    }
    ...
}

// Example in contract
$data['npzId'] = $this->npzId();

// Example in documents
public function documents()
{
    // Get npz id
    $npzId = $this->npzId();

    // Get documents
    $documents = $this->callApiWithCheck(
        $this->appWsApiUrl . 'amc-rest-service/greenbox/printed-matters/' . $npzId,
        '',
        'get'
    );
    ...
}

origin(): string

*Old product

/**
 * Get origin number
 *
 * @return string
 */

// Example
$this->apiUrl = 'https://online.allianzsp.sk/cestovne-poistenie/calc/?origin=' . $this->origin() . '&func=';

paymentMethod(bool $initial): string|array

*New product

/**
 * Get payment method id
 *
 * @param boolean $initial (true if initialPayment paramter)
 * @return string|array
 */

// Example
$data = [
    ...
    'initialPayment' => [
        'paymentMethod' => $this->paymentMethod(true),
    ],
    'subsequentPayment' => [
        'paymentMethod' => $this->paymentMethod(false),
    ],
    ...
];

setPassword(string $password)

*Old product

/**
 * Set password to open allianz email files
 *
 * @param string $password
 * @return void
 */

// Example
    // Parse response
    $result = $this->parseXml($result, [
        'contract_number' => [
            'uses' => 'RESULT.CPZ'
        ],
        'pdf' => [
            'uses' => 'RESULT.PDF'
        ],
        'pass' => [
            'uses' => 'RESULT.HESLO'
        ]
    ]);

    // Check if contract number
    if (!empty($result['contract_number'])) {
        $this->setContractNumber($result['contract_number']);
        $this->contractPdf = str_replace(['==]]>', '<![CDATA['], '', $result['pdf']);
        $this->setPassword($result['pass']);
        return true;
    } else {
        // !!! do something
    }

vehicleCarBrand(): string

*New product

/**
 * Get value for vehicle -> carBrand parameter
 *
 * @return string
 */

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

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

Custom parsers

  • parseBirth($birth, bool $onlyDate = false) // use: 'birthDate' => $this->parseBirth($policyholder->birth, true)
  • parseNationality($country) // use: 'nationality' => $this->parseNationality($policyholder->country)
  • parsePersonType($type) // use: 'partnerType' => $this->parsePersonType($policyholder[Field::LEGAL_FORM]),

Automatically parsed fields

  • Field::COLOR (new product type, returns array)
  • Field::FUEL (new product type, returns array)
  • Field::PAYMENT_METHOD (new product type, returns array) parsePaymentMethod($pm) see paymentMethod() helper
  • Field::PAYMENT_FREQUENCY (new product type, returns array) parseInsuranceFrequency($freq)
  • Field::VEHICLE_BRAND (new product type, returns external value from maps)
  • Field::VEHICLE_PURPOSE (new product type, returns array)
  • Field::VEHICLE_TYPE (new product type, returns array)