You are here

public static function FedExAddressResolver::addressResolveIE in Commerce FedEx 8

Resolve Addresses in Ireland.

Parameters

\Drupal\address\AddressInterface $address: The address to resolve.

Return value

\NicholasCreativeMedia\FedExPHP\Structs\Party A Fedex Compatible party.

File

src/FedExAddressResolver.php, line 114

Class

FedExAddressResolver
Allow Country level modifications when converting Drupal addresses to fedex.

Namespace

Drupal\commerce_fedex

Code

public static function addressResolveIE(AddressInterface $address) {
  $provinces = [
    'Co. Carlow' => 'N0',
    'Co. Cavan' => 'N1',
    'Co.  Clare' => 'N2',
    'Co. Cork' => ' N3',
    'Co.  Donegal' => 'N4',
    'Co. Dublin' => 'N5',
    'Co. Galway' => 'N6',
    'Co. Kerry' => 'N7',
    'Co. Kildare' => 'N8',
    'Co. Kilkenny' => 'N9',
    'Co. Laois' => 'NA',
    'Co. Leitrim' => 'NG',
    'Co. Limerick' => 'NI',
    'Co. Longford' => 'NK',
    'Co. Louth' => 'NL',
    'Co. Mayo' => 'NM',
    'Co. Meath' => 'NO',
    'Co. Monaghan' => 'NP',
    'Co. Offaly' => 'NQ',
    'Co. Roscommon' => 'NR',
    'Co. Sligo' => 'NW',
    'Co. Tipperary' => 'NX',
    'Co. Tipperary' => 'NY',
    'Co. Waterford' => 'NZ',
    'Co. Westmeath' => '10',
    'Co. Wexford' => '11',
    'Co. Wicklow' => '12',
  ];
  $party = new Party();
  $party
    ->setAddress(new Address(array_filter([
    $address
      ->getAddressLine1(),
    $address
      ->getAddressLine2(),
  ]), $address
    ->getAdministrativeArea(), $provinces[$address
    ->getAdministrativeArea()], $address
    ->getPostalCode(), NULL, $address
    ->getCountryCode(), NULL, FALSE));
  return $party;
}