exertis/yii2-experian-qas

Experian QAS Pro On Demand Postocde lookup SOAP service integration for the Yii framework. See also http://support.qas.com/experian_qas_pro_ondemand__php_only__technical_update_2021.htm

Installs: 17

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 5

Forks: 0

Type:yii2-extension

dev-master 2015-11-17 17:51 UTC

This package is not auto-updated.

Last update: 2024-05-25 15:29:19 UTC


README

Packaging Experian QAS Pro On Demand for Yii2 and Packagist

Rough Usage Example

This example is based on the Yii2 Framework, hence \Yii::$app->params['qas.username'] and \Yii::$app->params['qas.password'] will yield username and password from the Yii parameters file.

This example performs the setup and search.

        define("CONTROL_WSDL_URN", "https://your.wsdl.storage/ProOnDemandService.wsdl");

        $qas = new \exertis\experianqas\QuickAddress(CONTROL_WSDL_URN);

        if (empty($qas)) {
            throw new Exception('QAS: Initial connection failed');
        }

        $qas->setQASCredentials(\Yii::$app->params['qas.username'], \Yii::$app->params['qas.password']);

        // Find out available DataSets
        $aDataSets = $qas->getAllDataSets();
        $sPromptSet = $qas->getPromptSet('GBR');
        $layouts = $qas->getAllLayouts('GBR');

        # Perform the initial search (singleline engine, flattened picklists)
        $qas->setEngineType(QAS_SINGLELINE_ENGINE);
        $qas->setFlatten(TRUE);
        $picklist = $qas->searchSingleline('GBR', [$postcode], 'Optimal');

The result is a 'picklist' which you could process as follows:

        if (!empty($picklist->atItems) && is_array($picklist->atItems)) {
            // loop through each possible matched address
            $addresses = [];

            foreach ($picklist->atItems as $atItem) {

                //$formattedAddress = $qas->getFormattedAddress('QADefault', $atItem->Moniker);
                $formattedAddress = $qas->getFormattedAddress('FullPAF', $atItem->Moniker); // FormattedAddress

                $address = [

                        'picklistvalue' => $atItem->Picklist,
                        'flatNumber' => $formattedAddress->atAddressLines[5]->Line, // Sub-building name
                        'houseName' => $formattedAddress->atAddressLines[7]->Line, // Building name
                        'houseNumber' => $formattedAddress->atAddressLines[8]->Line, // Building number
                        'streetName' => $formattedAddress->atAddressLines[15]->Line, // Thoroughfare
                        'locality' => $formattedAddress->atAddressLines[18]->Line, // Dependent locality
                        'town' => $formattedAddress->atAddressLines[20]->Line, // Town
                        'county' => $formattedAddress->atAddressLines[21]->Line, // County
                        'id' => $atItem->Moniker,
                ];

                $addresses[] = $address;
            } // foreach