/**
  * Convert a customer address object to an address object compatible
  * with the address validation service.
  *
  * @param CustomerAddressInterface
  * @return \EbayEnterprise\Address\Api\Data\AddressInterface
  */
 public function convertCustomerAddressToDataAddress(CustomerAddressInterface $address)
 {
     // When the region object on the customer address already has a region
     // code, it isn't necessary to load the direction region model to get the code.
     $customerRegion = $address->getRegion();
     $region = $this->regionHelper->loadRegion($customerRegion->getRegionId(), $customerRegion->getRegionCode(), $customerRegion->getRegion(), $address->getCountryId());
     $data = ['street' => array_filter($address->getStreet(), [$this, 'filterEmptyStreets']), 'city' => $address->getCity(), 'region_code' => $region->getCode(), 'region_id' => $region->getId(), 'region_name' => $region->getName(), 'country_id' => $address->getCountryId(), 'postcode' => $address->getPostcode()];
     return $this->addressFactory->create(['data' => $data]);
 }
 /**
  * @param SdkHelper
  * @param IValidationReply
  * @param AddressInterfaceFactory
  * @param AddressInterface
  */
 public function __construct(SdkHelper $sdkHelper, IValidationReply $replyPayload, AddressInterfaceFactory $addressFactory, AddressInterface $originalAddress)
 {
     $this->id = uniqid('AVR-');
     $this->originalAddress = $originalAddress;
     // Extract data from the payload so the payload instance doesn't need
     // to be stored (may not be session safe and this object may need
     // to go into the session).
     $this->isValid = $replyPayload->isValid();
     $this->isAcceptable = $replyPayload->isAcceptable();
     $this->resultCode = $replyPayload->getResultCode();
     $this->errorLocations = [];
     foreach ($replyPayload->getErrorLocations() as $errorLocation) {
         $this->errorLocations[] = $errorLocation->getFieldName();
     }
     $this->hasSuggestions = $replyPayload->hasSuggestions();
     $this->suggestions = [];
     foreach ($replyPayload->getSuggestedAddresses() as $suggestedAddress) {
         $this->suggestions[uniqid('AVS-')] = $sdkHelper->transferPhysicalAddressPayloadToAddress($suggestedAddress, $addressFactory->create());
     }
     $this->suggestionCount = $replyPayload->getResultSuggestionCount();
     $this->correctedAddress = $sdkHelper->transferPhysicalAddressPayloadToAddress($replyPayload, $addressFactory->create());
 }