From a089caf538b506cca4ce9175805ce3d1e561c071 Mon Sep 17 00:00:00 2001 From: jeremy Date: Thu, 4 Jan 2018 09:29:21 -0600 Subject: [PATCH 1/5] Add Hong Kong Resolver. --- src/FedExAddressResolver.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/FedExAddressResolver.php b/src/FedExAddressResolver.php index 9f02e06..edf6c61 100644 --- a/src/FedExAddressResolver.php +++ b/src/FedExAddressResolver.php @@ -47,5 +47,32 @@ public static function addressResolveAU(AddressInterface $address) { return $party; } + + /** + * Resolve Addresses in Hong Kong. + * + * @param \Drupal\address\AddressInterface $address + * The address to resolve. + * + * @return \NicholasCreativeMedia\FedExPHP\Structs\Party + * A Fedex Compatible party. + */ + public static function addressResolveHK(AddressInterface $address) { + + $party = new Party(); + + $party->setAddress(new Address( + array_filter([$address->getAddressLine1(), $address->getAddressLine2()]), + $address->getAdministrativeArea().', '.$address->getLocality(), + NULL, + $address->getPostalCode(), + NULL, + $address->getCountryCode(), + NULL, + FALSE + )); + + return $party; + } } From 1f503b726322544f19fa3dda42cfaac2392128aa Mon Sep 17 00:00:00 2001 From: jeremy Date: Mon, 15 Jan 2018 10:48:52 -0600 Subject: [PATCH 2/5] Added a fix for Barbados. --- src/FedExAddressResolver.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/FedExAddressResolver.php b/src/FedExAddressResolver.php index edf6c61..6631db1 100644 --- a/src/FedExAddressResolver.php +++ b/src/FedExAddressResolver.php @@ -47,7 +47,7 @@ public static function addressResolveAU(AddressInterface $address) { return $party; } - + /** * Resolve Addresses in Hong Kong. * @@ -74,5 +74,23 @@ public static function addressResolveHK(AddressInterface $address) { return $party; } + + public static function addressResolveBB(AddressInterface $address) { + + $party = new Party(); + + $party->setAddress(new Address( + array_filter([$address->getAddressLine1(), $address->getAddressLine2()]), + $address->getAdministrativeArea(), + NULL, + $address->getPostalCode(), + NULL, + $address->getCountryCode(), + NULL, + FALSE + )); + + return $party; + } } From bcd6fc7d217a36c3e2e7e99f0dd77a1a44d85be8 Mon Sep 17 00:00:00 2001 From: jeremy Date: Mon, 15 Jan 2018 10:50:51 -0600 Subject: [PATCH 3/5] Added Comments --- src/FedExAddressResolver.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/FedExAddressResolver.php b/src/FedExAddressResolver.php index 6631db1..8861e80 100644 --- a/src/FedExAddressResolver.php +++ b/src/FedExAddressResolver.php @@ -75,6 +75,15 @@ public static function addressResolveHK(AddressInterface $address) { return $party; } + /** + * Resolve Addresses in Barbados. + * + * @param \Drupal\address\AddressInterface $address + * The address to resolve. + * + * @return \NicholasCreativeMedia\FedExPHP\Structs\Party + * A Fedex Compatible party. + */ public static function addressResolveBB(AddressInterface $address) { $party = new Party(); From 2be6f013f0bf81e8b3e00b9efb3efc7d91ae889b Mon Sep 17 00:00:00 2001 From: jeremy Date: Mon, 15 Jan 2018 15:56:51 -0600 Subject: [PATCH 4/5] Add Ireland Mapping --- src/FedExAddressResolver.php | 79 +++++++++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 10 deletions(-) diff --git a/src/FedExAddressResolver.php b/src/FedExAddressResolver.php index 8861e80..28d7697 100644 --- a/src/FedExAddressResolver.php +++ b/src/FedExAddressResolver.php @@ -58,12 +58,12 @@ public static function addressResolveAU(AddressInterface $address) { * A Fedex Compatible party. */ public static function addressResolveHK(AddressInterface $address) { - + $party = new Party(); - + $party->setAddress(new Address( array_filter([$address->getAddressLine1(), $address->getAddressLine2()]), - $address->getAdministrativeArea().', '.$address->getLocality(), + $address->getAdministrativeArea() . ', ' . $address->getLocality(), NULL, $address->getPostalCode(), NULL, @@ -71,12 +71,12 @@ public static function addressResolveHK(AddressInterface $address) { NULL, FALSE )); - + return $party; } - + /** - * Resolve Addresses in Barbados. + * Resolve Addresses in Barbodos. * * @param \Drupal\address\AddressInterface $address * The address to resolve. @@ -84,10 +84,10 @@ public static function addressResolveHK(AddressInterface $address) { * @return \NicholasCreativeMedia\FedExPHP\Structs\Party * A Fedex Compatible party. */ - public static function addressResolveBB(AddressInterface $address) { - + public static function addressResolveBB(AddressInterface $address) { + $party = new Party(); - + $party->setAddress(new Address( array_filter([$address->getAddressLine1(), $address->getAddressLine2()]), $address->getAdministrativeArea(), @@ -98,7 +98,66 @@ public static function addressResolveBB(AddressInterface $address) { NULL, FALSE )); - + + return $party; + } + + /** + * Resolve Addresses in Ireland. + * + * @param \Drupal\address\AddressInterface $address + * The address to resolve. + * + * @return \NicholasCreativeMedia\FedExPHP\Structs\Party + * A Fedex Compatible party. + */ + 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; } From b4129ddf058e7307ba319e93ed8ff3fccf5457ce Mon Sep 17 00:00:00 2001 From: jeremy Date: Wed, 7 Feb 2018 11:18:02 -0600 Subject: [PATCH 5/5] Fixed a typo. --- src/FedExAddressResolver.php | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/FedExAddressResolver.php b/src/FedExAddressResolver.php index 28d7697..05431c8 100644 --- a/src/FedExAddressResolver.php +++ b/src/FedExAddressResolver.php @@ -71,23 +71,14 @@ public static function addressResolveHK(AddressInterface $address) { NULL, FALSE )); - + return $party; } - - /** - * Resolve Addresses in Barbodos. - * - * @param \Drupal\address\AddressInterface $address - * The address to resolve. - * - * @return \NicholasCreativeMedia\FedExPHP\Structs\Party - * A Fedex Compatible party. - */ - public static function addressResolveBB(AddressInterface $address) { - + + public static function addressResolveBB(AddressInterface $address) { + $party = new Party(); - + $party->setAddress(new Address( array_filter([$address->getAddressLine1(), $address->getAddressLine2()]), $address->getAdministrativeArea(), @@ -116,9 +107,9 @@ public static function addressResolveIE(AddressInterface $address) { $provinces = [ 'Co. Carlow' => 'N0', 'Co. Cavan' => 'N1', - 'Co. Clare' => 'N2', + 'Co. Clare' => 'N2', 'Co. Cork' => ' N3', - 'Co. Donegal' => 'N4', + 'Co. Donegal' => 'N4', 'Co. Dublin' => 'N5', 'Co. Galway' => 'N6', 'Co. Kerry' => 'N7',