public function doEnhancement(Lead $lead)
    {
        if (!empty($lead)) {
            if ($lead->getFieldValue('alcazar_lrn') || !$lead->getPhone()) {
                return false;
            }

            $phone = $lead->getPhone();
            $phone = preg_replace('/[^0-9]/', '', $phone);
            if (10 === strlen($phone)) {
                $phone = '1'.$phone;
            }
            if (11 !== strlen($phone)) {
                return false;
            }

            $keys = $this->getKeys();

            $params = [
                'key' => $keys['apikey'],
                'tn'  => $phone,
            ];

            $features = $this->getIntegrationSettings()->getFeatureSettings();
            foreach ($features as $param => $value) {
                if ('ani' === $param) {
                    //the value of ani should be a phone number
                    //but this service is currently unused
                    continue;
                } elseif ('output' === $param) {
                    $params['output'] = $value;
                } elseif (in_array($param, ['extended', 'dnc'])) {
                    $params[$param] = ($value ? 'true' : 'false');
                }
            }

            $settings = [
                'ignore_event_dispatch' => 1,
                'curl_options'          => [CURLOPT_CONNECTTIMEOUT => 1, CURLOPT_TIMEOUT => 30],
            ];

            try {
                $response = $this->makeRequest(
                    $keys['server'],
                    ['append_to_query' => $params],
                    'GET',
                    $settings
                );
            } catch (\Exception $e) {
                $this->logger->error($e->getMessage());

                return false;
            }

            if ($response) {
                $this->applyCost($lead);

                $allowedAliases = $this->getEnhancerFieldArray();
                foreach ($response as $label => $value) {
                    $alias = 'alcazar_'.strtolower($label);
                    if (isset($allowedAliases[$alias])) {
                        $default = $lead->getFieldValue($alias);
                        $lead->addUpdatedField($alias, $value, $default);
                    }
                }

                return true;
            }

            return false;
        }
    }
public function doEnhancement(Lead $lead)
    {
        if (!empty($lead)) {
            if ($lead->getFieldValue('alcazar_lrn') || !$lead->getPhone()) {
                return false;
            }

            $phone = $lead->getPhone();
            $phone = preg_replace('/[^0-9]/', '', $phone);
            if (10 === strlen($phone)) {
                $phone = '1'.$phone;
            }
            if (11 !== strlen($phone)) {
                return false;
            }

            $keys = $this->getKeys();

            $params = [
                'key' => $keys['apikey'],
                'tn'  => $phone,
            ];

            $features = $this->getIntegrationSettings()->getFeatureSettings();
            foreach ($features as $param => $value) {
                if ('ani' === $param) {
                    //the value of ani should be a phone number
                    //but this service is currently unused
                    continue;
                } elseif ('output' === $param) {
                    $params['output'] = $value;
                } elseif (in_array($param, ['extended', 'dnc'])) {
                    $params[$param] = ($value ? 'true' : 'false');
                }
            }

            $settings = [
                'ignore_event_dispatch' => 1,
                'curl_options'          => [CURLOPT_CONNECTTIMEOUT => 1, CURLOPT_TIMEOUT => 30],
            ];

            try {
                $response = $this->makeRequest(
                    $keys['server'],
                    ['append_to_query' => $params],
                    'GET',
                    $settings
                );
            } catch (\Exception $e) {
                $this->logger->error($e->getMessage());

                return false;
            }

            if ($response) {
                $this->applyCost($lead);

                $allowedAliases = $this->getEnhancerFieldArray();
                foreach ($response as $label => $value) {
                    $alias = 'alcazar_'.strtolower($label);
                    if (isset($allowedAliases[$alias])) {
                        $default = $lead->getFieldValue($alias);
                        $lead->addUpdatedField($alias, $value, $default);
                    }
                }

                return true;
            }

            return false;
        }
    }
@param Lead $lead

@return bool