Integration/XverifyIntegration.php
public function doEnhancement(Lead $lead)
    {
        $persist = false;
        if (!empty($lead)) {
            $settings            = $this->getIntegrationSettings()->getFeatureSettings();
            $contactFieldMapping = $settings['leadFields'];
            $keys                = $this->getKeys();

            $params = [
                'apikey' => $keys['apikey'],
                'domain' => $keys['server'],
                'type'   => 'json',
            ];

            foreach ($contactFieldMapping as $integrationFieldName => $mauticFieldName) {
                $fieldToUpdate = $integrationFieldName.'_valid'; //which validation field will we update?
                try {
                    $fieldValue = $lead->getFieldValue($mauticFieldName);
                    if (!empty($fieldValue)) {
                        switch ($integrationFieldName) {
                            case 'cellphone':
                            case 'homephone':
                            case 'workphone':
                                // phone API call
                                $service  = 'phone';
                                $fieldKey = 'phone';
                                if (is_null(
                                    $lead->getFieldValue($fieldToUpdate)
                                )) { // only if we havent checked already
                                    $response = $this->makeCall($service, $params, $fieldKey, $fieldValue);
                                    $this->applyCost($lead);
                                    $persist = true;
                                    $status  = $this->getResponseStatus($response, $fieldKey);
                                    if (!is_null($status)) {
                                        $lead->addUpdatedField($fieldToUpdate, $status);
                                        $this->logger->addDebug(
                                            'XVERIFY: verification values to update: '.$fieldToUpdate.' => '.$status
                                        );
                                    }
                                }
                                break;

                            case 'email':
                                // email API call
                                $service  = 'emails';
                                $fieldKey = 'email';
                                if (is_null(
                                    $lead->getFieldValue($fieldToUpdate)
                                )) { // only if we havent checked already
                                    $response = $this->makeCall($service, $params, $fieldKey, $fieldValue);
                                    $this->applyCost($lead);
                                    $persist = true;
                                    $status  = $this->getResponseStatus($response, $fieldKey);
                                    if (!is_null($status)) {
                                        $lead->addUpdatedField($fieldToUpdate, $status, null);
                                        $this->logger->addDebug(
                                            'XVERIFY: verification values to update: '.$fieldToUpdate.' => '.$status
                                        );
                                    }
                                }
                                break;

                            default:      // no matching case
                                continue; // dont do anything - go to next loop iteration
                        }
                    }
                } catch (\Exception $e) {
                    $this->logIntegrationError($e);

                    return false;
                }
            }
        }

        return $persist;
    }
public function doEnhancement(Lead $lead)
    {
        $persist = false;
        if (!empty($lead)) {
            $settings            = $this->getIntegrationSettings()->getFeatureSettings();
            $contactFieldMapping = $settings['leadFields'];
            $keys                = $this->getKeys();

            $params = [
                'apikey' => $keys['apikey'],
                'domain' => $keys['server'],
                'type'   => 'json',
            ];

            foreach ($contactFieldMapping as $integrationFieldName => $mauticFieldName) {
                $fieldToUpdate = $integrationFieldName.'_valid'; //which validation field will we update?
                try {
                    $fieldValue = $lead->getFieldValue($mauticFieldName);
                    if (!empty($fieldValue)) {
                        switch ($integrationFieldName) {
                            case 'cellphone':
                            case 'homephone':
                            case 'workphone':
                                // phone API call
                                $service  = 'phone';
                                $fieldKey = 'phone';
                                if (is_null(
                                    $lead->getFieldValue($fieldToUpdate)
                                )) { // only if we havent checked already
                                    $response = $this->makeCall($service, $params, $fieldKey, $fieldValue);
                                    $this->applyCost($lead);
                                    $persist = true;
                                    $status  = $this->getResponseStatus($response, $fieldKey);
                                    if (!is_null($status)) {
                                        $lead->addUpdatedField($fieldToUpdate, $status);
                                        $this->logger->addDebug(
                                            'XVERIFY: verification values to update: '.$fieldToUpdate.' => '.$status
                                        );
                                    }
                                }
                                break;

                            case 'email':
                                // email API call
                                $service  = 'emails';
                                $fieldKey = 'email';
                                if (is_null(
                                    $lead->getFieldValue($fieldToUpdate)
                                )) { // only if we havent checked already
                                    $response = $this->makeCall($service, $params, $fieldKey, $fieldValue);
                                    $this->applyCost($lead);
                                    $persist = true;
                                    $status  = $this->getResponseStatus($response, $fieldKey);
                                    if (!is_null($status)) {
                                        $lead->addUpdatedField($fieldToUpdate, $status, null);
                                        $this->logger->addDebug(
                                            'XVERIFY: verification values to update: '.$fieldToUpdate.' => '.$status
                                        );
                                    }
                                }
                                break;

                            default:      // no matching case
                                continue; // dont do anything - go to next loop iteration
                        }
                    }
                } catch (\Exception $e) {
                    $this->logIntegrationError($e);

                    return false;
                }
            }
        }

        return $persist;
    }
@param Lead $lead

@return bool