Get the address.

@param \Paysafe\CustomerVault\Address $address
@return bool
@throws PaysafeException
177374
public function getAddress( CustomerVault\Address $address )
    {
        $address->setRequiredFields(array(
            'profileID',
            'id'
        ));
        $address->checkRequiredFields();

        $request = new Request(array(
            'method' => Request::GET,
            'uri' => $this->prepareURI("/profiles/" . $address->profileID . "/addresses/" . $address->id),
        ));
        $response = $this->client->processRequest($request);
        $response['profileID'] = $address->profileID;

        return new CustomerVault\Address($response);
    }
860674
public function getAddressRaw($address, \DateTime $from = null)
    {
        $result = false;

        $response = $this->request(sprintf('/api/address/%s/raw', $address));

        if ($response !== false && is_array($response)) {
            $result = [];
            foreach ($response as $data) {
                $transaction = new Transaction($data);

                if ($transaction->getOutAmount($address) !== false) {
                    if ($from === null || $transaction->getTime() > $from) {
                        $result[] = $transaction;
                    }
                }
            }
        }

        return $result;
    }
657219
public function geolocateIPAddress(AddressInterface $address)
    {
        $result = new GeolocationResult();
        try {
            switch ($address->getRangeType()) {
                case IPRangeType::T_PUBLIC:
                    $addressString = (string) $address;
                    $session = $this->app->make('session');
                    $sessionKey = 'ccm/geolocation/' . $this->geolocator->getGeolocatorHandle() . '/' . $this->geolocator->getGeolocatorID() . '/' . md5(serialize($this->geolocator->getGeolocatorConfiguration())) . '/' . $addressString;
                    if ($session->has($sessionKey)) {
                        $result = $session->get($sessionKey);
                    } else {
                        $result = $this->performGeolocation($address);
                        $session->set($sessionKey, $result);
                    }
                    break;
                default:
                    $result->setError(GeolocationResult::ERR_IPNOTPUBLIC);
                    break;
            }
        } catch (Exception $x) {
            $result->setError(GeolocationResult::ERR_OTHER, '', $x);
        } catch (Throwable $x) {
            $result->setError(GeolocationResult::ERR_OTHER, '', new Exception($x->getMessage(), $x->getCode()));
        }

        return $result;
    }
1028965
protected function getAddressZoneId(array $address)
    {
        $result = array();

        foreach (array('state_id', 'city_id', 'country') as $field) {

            if (empty($address[$field])) {
                continue;
            }

            if ($field === 'city_id') {
                $data = $this->city->get($address[$field]);
            } else if ($field === 'state_id') {
                $data = $this->state->get($address[$field]);
            } else if ($field === 'country') {
                $data = $this->country->get($address[$field]);
            }

            if (!empty($data['zone_id'])) {
                $result[] = $data['zone_id'];
            }
        }

        return $result;
    }
203275
protected function extractAddressValues(AddressInterface $address)
    {
        $values = [];
        foreach (AddressField::getAll() as $field) {
            $getter = 'get' . ucfirst($field);
            $values[$field] = $address->$getter();
        }

        return $values;
    }
1319141
public function address(array $address)
    {
        if (! isset($this->data->addresses)) {
            $this->data->addresses = [];
        }

        return $this->data->addresses[] = (object) $address;
    }
257246
public function geocodeAddress($address)
	{
		$uri = new Uri('https://maps.googleapis.com/maps/api/geocode/json');

		$uri->setVar('address', urlencode($address));

		if (($key = $this->getKey()))
		{
			$uri->setVar('key', $key);
		}

		$response = $this->http->get($uri->toString());

		if ($response->code < 200 || $response->code >= 300)
		{
			throw new RuntimeException('Error code ' . $response->code . ' received geocoding address: ' . $response->body . '.');
		}

		$data = json_decode($response->body, true);

		if (!$data)
		{
			throw new RuntimeException('Invalid json received geocoding address: ' . $response->body . '.');
		}

		if ($data['status'] != 'OK')
		{
			return;
		}

		return $data['results'][0];
	}
450545
public function createAddress(int $customerId, Address $address): ?int
    {
        return $this->restClient->createResource(
            $address,
            sprintf(self::CUSTOMER_ADDRESS, $customerId)
        );
    }
1097766
protected function getFromCache($address, $country)
    {
        $builder = $this->connection->createQueryBuilder();
        $builder
            ->select('*')
            ->from($this->connection->quoteIdentifier('tl_metamodel_perimetersearch'))
            ->where($builder->expr()->eq($this->connection->quoteIdentifier('search'), ':search'))
            ->andWhere($builder->expr()->eq($this->connection->quoteIdentifier('country'), ':country'))
            ->setParameter('search', $address)
            ->setParameter('country', $country);

        $statement = $builder->execute();

        // If we have no data just return null.
        if (!$statement->rowCount()) {
            return null;
        }

        $result = $statement->fetch(\PDO::FETCH_OBJ);

        // Build a new container.
        $container = new Container();
        $container->setLatitude($result->geo_lat);
        $container->setLongitude($result->geo_long);
        $container->setSearchParam(
            \strtr(
                $builder->getSQL(),
                [
                    ':search'  => $this->connection->quote($address),
                    ':country' => $this->connection->quote($country)
                ]
            )
        );

        return $container;
    }
1057087
public function getAddress($index)
    {
        if (!isset($this->addresses[$index])) {
            return null;
        }
        return $this->addresses[$index];
    }
410905
private function normalizeAddress($address) {
    if (isset($address->extension)) {
      if (!is_object($address->extension)) {
        $anObject = (object) $address->extension;
        $address->extension = $anObject;
      }
    }
    return $address;
  }
1338582
public function getBalance($address)
    {
        $response = $this->apiClient->get('tokens/balance', [
            'token_uid' => $this->tokenUid,
            'address' => $address,
        ]);

        if (!isset($response['balance'])) throw new \ErrorException('Unexpected API response: ' . print_r($response, true));

        return $response['balance'];
    }
1074561
public static function parse(string $address)
    {
        static $regex = null;
        if (null === $regex) {
            $grammar = Grammar::getInstance();

            $addrSpec = $grammar->getDefinition('addr-spec');
            $cfws = $grammar->getDefinition('CFWS');
            $phrase = $grammar->getDefinition('phrase');

            $regex = '/(?<address>'.$addrSpec.')|(?:(?<name>'.$phrase.')(?:'.$cfws.'?)<(?<addressalt>'.$addrSpec.')>(?:'.$cfws.'?))/';
        }

        if (! \preg_match($regex, $address, $match)) {
            return null;
        }

        $addr = isset($match['addressalt']) ? $match['addressalt'] : $match['address'];

        $name = $match['name'] ?? '';
        $name = \trim($name, " \t\n\r\0\x0B\"");

        return [
            'address' => $addr,
            'personal' => $name,
        ];
    }
630635
public function getCoordinates($address)
    {
        if (! empty($this->country)) {
            $address = trim($address) . ' ' . $this->country;
        }

        // Sanitize the address:
        $search_code = urlencode($address);

        // Retrieve the latitude and longitude
        $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . $search_code . '&sensor=false';

        // If Google Maps API fails, catch it and throw a better error
        $json = $this->api->fetch($url);

        if(!empty($json->results)) {
            $lat = $json->results[0]->geometry->location->lat;
            $lng = $json->results[0]->geometry->location->lng;

            return [
                'latitude'  => $lat,
                'longitude' => $lng
            ];
        }

        // We must have nothing if we've got here
        return [];
    }
121363
public function getEntry(Address $address)
    {
        try {
            $sth = $this->dbh->prepare('SELECT "event_id", "pool", "address", "value", "created", "expiration" FROM ' . $this->prefixTable('lcache_events') .' WHERE "address" = :address AND ("expiration" >= :now OR "expiration" IS NULL) ORDER BY "event_id" DESC LIMIT 1');
            $sth->bindValue(':address', $address->serialize(), \PDO::PARAM_STR);
            $sth->bindValue(':now', $_SERVER['REQUEST_TIME'], \PDO::PARAM_INT);
            $sth->execute();
        } catch (\PDOException $e) {
            $this->logSchemaIssueOrRethrow('Failed to search database for cache item', $e);
            return null;
        }
        //$last_matching_entry = $sth->fetchObject('LCacheEntry');
        $last_matching_entry = $sth->fetchObject();

        if (false === $last_matching_entry) {
            $this->misses++;
            return null;
        }

        // If last event was a deletion, miss.
        if (is_null($last_matching_entry->value)) {
            $this->misses++;
            return null;
        }

        $unserialized_value = @unserialize($last_matching_entry->value);

        // If unserialization failed, raise an exception.
        if (false === $unserialized_value && serialize(false) !== $last_matching_entry->value) {
            throw new UnserializationException($address, $last_matching_entry->value);
        }

        $last_matching_entry->value = $unserialized_value;
        $this->hits++;
        return $last_matching_entry;
    }
1140753
public function getAddress( $domain = MShop_Order_Item_Base_Address_Abstract::TYPE_PAYMENT )
	{
		if(!isset($this->_addresses[$domain])) {
			throw new MShop_Order_Exception( sprintf( 'Address for domain "%1$s" not available', $domain ) );
		}

		return $this->_addresses[$domain];
	}
119705
public function deleteAddress(Address $address)
    {
        if ($this !== $address->addressable()->first())
            return false;

        return $address->delete();
    }