From 6f5cfdabd5ee80f57a729c5db6d8a9ce9f294c13 Mon Sep 17 00:00:00 2001 From: Ismail Ashour Date: Fri, 8 Nov 2019 22:20:57 +0200 Subject: [PATCH] Change functions to run & add aramex facade --- README.md | 52 ++++++++--------- src/API/Requests/Location/FetchCities.php | 2 +- src/API/Requests/Location/FetchCountries.php | 2 +- src/API/Requests/Location/FetchCountry.php | 2 +- src/API/Requests/Location/FetchOffices.php | 2 +- src/API/Requests/Location/FetchStates.php | 2 +- src/API/Requests/Location/ValidateAddress.php | 2 +- src/API/Requests/Rate/CalculateRate.php | 2 +- src/API/Requests/Shipping/CancelPickup.php | 2 +- src/API/Requests/Shipping/CreatePickup.php | 2 +- src/API/Requests/Shipping/CreateShipments.php | 2 +- .../Shipping/GetLastShipmentsNumbersRange.php | 2 +- src/API/Requests/Shipping/PrintLabel.php | 2 +- .../Shipping/ReserveShipmentNumberRange.php | 2 +- .../Requests/Shipping/ScheduleDelivery.php | 2 +- src/API/Requests/Tracking/TrackPickup.php | 2 +- src/API/Requests/Tracking/TrackShipments.php | 2 +- src/Aramex.php | 34 +++++------ src/AramexFacade.php | 57 +++++++++++++++++++ 19 files changed, 116 insertions(+), 59 deletions(-) create mode 100644 src/AramexFacade.php diff --git a/README.md b/README.md index 331431f..13a8e9c 100644 --- a/README.md +++ b/README.md @@ -42,36 +42,36 @@ Run the following command to install the latest applicable version of the packag #### Fetch Countries This method allows users to get the world countries list. - Aramex::FetchCountries()->make(); + Aramex::fetchCountries()->run(); #### Fetch Country This method allows users to get details of a certain country. - Aramex::FetchCountry() + Aramex::fetchCountry() ->setCode('PS') - ->make(); + ->run(); #### Fetch States This method allows users to get all the states within a certain country (country code). - Aramex::FetchStates() + Aramex::fetchStates() ->setCountryCode('AE') - ->make(); + ->run(); #### Fetch Cities This method allows users to get all the cities within a certain country (country code). And allows users to get list of the cities that start with a specific prefix. The required nodes to be filled are Client Info and Country Code. - Aramex::FetchCities() + Aramex::fetchCities() ->setCountryCode('AE') - ->make(); + ->run(); #### Validate Address This method Allows users to search for certain addresses and make sure that the address structure is correct. - Aramex::ValidateAddress() + Aramex::validateAddress() ->setAddress( (new Address()) ... - )->make() + )->run(); ### Rate @@ -84,12 +84,12 @@ This method allows users to get rate for source/destinations shipment. $details = (new ShipmentDetails()) ...; - Aramex::CalculateRate() + Aramex::calculateRate() ->setOriginalAddress($source) ->setDestinationAddress($destination) ->setShipmentDetails($details) ->setPreferredCurrencyCode('USD') - ->make(); + ->run(); ### Shipping @@ -118,30 +118,30 @@ This method allows users to create a pickup request. ->setReportId(9201) ->setReportType('URL'); - Aramex::CreatePickup() + Aramex::createPickup() ->setLabelInfo($labelInfo) ->setPickup($pickup) - ->make(); + ->run(); #### Cancel Pickup This method allows you to cancel a pickup as long as it is un-assigned or pending details. - Aramex::CancelPickup() + Aramex::cancelPickup() ->setPickupGUID('PICKUP_GUID') - ->make(); + ->run(); #### Create Shipments This method allows users to create shipments on Aramex’s system. - Aramex::CreateShipments()->make(); + Aramex::createShipments()->run(); #### Get Last Shipments Numbers Range This method allows you to inquire about the last reserved range using a specific entity and product group - Aramex::GetLastShipmentsNumbersRange() + Aramex::getLastShipmentsNumbersRange() ->setEntity('ENTITY') ->setProductGroup('PRODUCT_GROUP') - ->make(); + ->run(); #### Print Label This method allows the user to print a label for an existing shipment. @@ -150,37 +150,37 @@ This method allows the user to print a label for an existing shipment. ->setReportId(9201) ->setReportType('URL'); - Aramex::PrintLabel() + Aramex::printLabel() ->setShipmentNumber('SHIPMENT_NO') ->setLabelInfo() - ->make(); + ->run(); #### Reserve Shipment Number Range This method allows you to reserve a range of shipment numbers. - Aramex::ReserveShipmentNumberRange()->make(); + Aramex::reserveShipmentNumberRange()->run(); #### Schedule Delivery This method allows you to schedule the delivery of a shipment at a specified time and place (Longitude and Latitude) - Aramex::ScheduleDelivery()->make(); + Aramex::scheduleDelivery()->run(); ### Tracking #### Track Pickup This method allows the user to track an existing pickup’s updates and latest status. - Aramex::TrackPickup() + Aramex::trackPickup() ->setReference('PICKUP_NO') ->setPickup('PICKUP') // any number - ->track(); + ->run(); #### Track Shipments This method allows the user to track an existing shipment’s updates and latest status. - Aramex::TrackShipments() + Aramex::trackShipments() ->setShipments(['SHIPMENT_NO']) - ->make(); + ->run(); ## Credits diff --git a/src/API/Requests/Location/FetchCities.php b/src/API/Requests/Location/FetchCities.php index c199fa0..ecea12a 100644 --- a/src/API/Requests/Location/FetchCities.php +++ b/src/API/Requests/Location/FetchCities.php @@ -27,7 +27,7 @@ class FetchCities extends API implements Normalize * @return CitiesFetchingResponse * @throws \Exception */ - public function make() + public function run() { $this->validate(); diff --git a/src/API/Requests/Location/FetchCountries.php b/src/API/Requests/Location/FetchCountries.php index af6e4b7..c44889c 100644 --- a/src/API/Requests/Location/FetchCountries.php +++ b/src/API/Requests/Location/FetchCountries.php @@ -21,7 +21,7 @@ class FetchCountries extends API implements Normalize * @return CountriesFetchingResponse * @throws \Exception */ - public function make() + public function run() { $this->validate(); diff --git a/src/API/Requests/Location/FetchCountry.php b/src/API/Requests/Location/FetchCountry.php index 25f64b5..e836643 100644 --- a/src/API/Requests/Location/FetchCountry.php +++ b/src/API/Requests/Location/FetchCountry.php @@ -24,7 +24,7 @@ class FetchCountry extends API implements Normalize * @return CountryFetchingResponse * @throws Exception */ - public function make() + public function run() { $this->validate(); diff --git a/src/API/Requests/Location/FetchOffices.php b/src/API/Requests/Location/FetchOffices.php index 9d33119..1c7c963 100644 --- a/src/API/Requests/Location/FetchOffices.php +++ b/src/API/Requests/Location/FetchOffices.php @@ -25,7 +25,7 @@ class FetchOffices extends API implements Normalize * @return OfficesFetchingResponse * @throws Exception */ - public function make() + public function run() { $this->validate(); diff --git a/src/API/Requests/Location/FetchStates.php b/src/API/Requests/Location/FetchStates.php index b6c5ae5..2319a5a 100644 --- a/src/API/Requests/Location/FetchStates.php +++ b/src/API/Requests/Location/FetchStates.php @@ -18,7 +18,7 @@ class FetchStates extends API implements Normalize * @return StatesFetchingResponse * @throws Exception */ - public function make() + public function run() { $this->validate(); diff --git a/src/API/Requests/Location/ValidateAddress.php b/src/API/Requests/Location/ValidateAddress.php index 2033fca..85c90dd 100644 --- a/src/API/Requests/Location/ValidateAddress.php +++ b/src/API/Requests/Location/ValidateAddress.php @@ -25,7 +25,7 @@ class ValidateAddress extends API implements Normalize * @return AddressValidationResponse * @throws \Exception */ - public function make() + public function run() { $this->validate(); diff --git a/src/API/Requests/Rate/CalculateRate.php b/src/API/Requests/Rate/CalculateRate.php index e17d883..7356133 100644 --- a/src/API/Requests/Rate/CalculateRate.php +++ b/src/API/Requests/Rate/CalculateRate.php @@ -31,7 +31,7 @@ public function __construct() * @return RateCalculatorResponse * @throws Exception */ - public function make() + public function run() { $this->validate(); diff --git a/src/API/Requests/Shipping/CancelPickup.php b/src/API/Requests/Shipping/CancelPickup.php index e0bdb84..3219421 100644 --- a/src/API/Requests/Shipping/CancelPickup.php +++ b/src/API/Requests/Shipping/CancelPickup.php @@ -25,7 +25,7 @@ class CancelPickup extends API implements Normalize * @return PickupCancellationResponse * @throws Exception */ - public function make(): PickupCancellationResponse + public function run(): PickupCancellationResponse { $this->validate(); diff --git a/src/API/Requests/Shipping/CreatePickup.php b/src/API/Requests/Shipping/CreatePickup.php index ff889a9..1344d05 100644 --- a/src/API/Requests/Shipping/CreatePickup.php +++ b/src/API/Requests/Shipping/CreatePickup.php @@ -28,7 +28,7 @@ class CreatePickup extends API implements Normalize * @return PickupCreationResponse * @throws Exception */ - public function make(): PickupCreationResponse + public function run(): PickupCreationResponse { $this->validate(); diff --git a/src/API/Requests/Shipping/CreateShipments.php b/src/API/Requests/Shipping/CreateShipments.php index 2e5dabe..f2efd4e 100644 --- a/src/API/Requests/Shipping/CreateShipments.php +++ b/src/API/Requests/Shipping/CreateShipments.php @@ -28,7 +28,7 @@ class CreateShipments extends API implements Normalize * @return ShipmentCreationResponse * @throws Exception */ - public function make(): ShipmentCreationResponse + public function run(): ShipmentCreationResponse { $this->validate(); diff --git a/src/API/Requests/Shipping/GetLastShipmentsNumbersRange.php b/src/API/Requests/Shipping/GetLastShipmentsNumbersRange.php index 4292a5e..452e3da 100644 --- a/src/API/Requests/Shipping/GetLastShipmentsNumbersRange.php +++ b/src/API/Requests/Shipping/GetLastShipmentsNumbersRange.php @@ -25,7 +25,7 @@ class GetLastShipmentsNumbersRange extends API implements Normalize * @return LastReservedShipmentNumberRangeResponse * @throws Exception */ - public function make(): LastReservedShipmentNumberRangeResponse + public function run(): LastReservedShipmentNumberRangeResponse { $this->validate(); diff --git a/src/API/Requests/Shipping/PrintLabel.php b/src/API/Requests/Shipping/PrintLabel.php index f939d91..b9ebebc 100644 --- a/src/API/Requests/Shipping/PrintLabel.php +++ b/src/API/Requests/Shipping/PrintLabel.php @@ -31,7 +31,7 @@ class PrintLabel extends API implements Normalize * @return LabelPrintingResponse * @throws Exception */ - public function make(): LabelPrintingResponse + public function run(): LabelPrintingResponse { $this->validate(); diff --git a/src/API/Requests/Shipping/ReserveShipmentNumberRange.php b/src/API/Requests/Shipping/ReserveShipmentNumberRange.php index 781874d..e2f61e0 100644 --- a/src/API/Requests/Shipping/ReserveShipmentNumberRange.php +++ b/src/API/Requests/Shipping/ReserveShipmentNumberRange.php @@ -26,7 +26,7 @@ class ReserveShipmentNumberRange extends API implements Normalize * @return ReserveRangeResponse * @throws Exception */ - public function make(): ReserveRangeResponse + public function run(): ReserveRangeResponse { $this->validate(); diff --git a/src/API/Requests/Shipping/ScheduleDelivery.php b/src/API/Requests/Shipping/ScheduleDelivery.php index ffc0552..1da1238 100644 --- a/src/API/Requests/Shipping/ScheduleDelivery.php +++ b/src/API/Requests/Shipping/ScheduleDelivery.php @@ -36,7 +36,7 @@ class ScheduleDelivery extends API implements Normalize * @return ScheduledDeliveryResponse * @throws Exception */ - public function make(): ScheduledDeliveryResponse + public function run(): ScheduledDeliveryResponse { $this->validate(); diff --git a/src/API/Requests/Tracking/TrackPickup.php b/src/API/Requests/Tracking/TrackPickup.php index 7dd29d7..fcf6838 100644 --- a/src/API/Requests/Tracking/TrackPickup.php +++ b/src/API/Requests/Tracking/TrackPickup.php @@ -26,7 +26,7 @@ class TrackPickup extends API implements Normalize * @return PickupTrackingResponse * @throws Exception */ - public function make() + public function run() { $this->validate(); diff --git a/src/API/Requests/Tracking/TrackShipments.php b/src/API/Requests/Tracking/TrackShipments.php index e0f0c44..a62924b 100644 --- a/src/API/Requests/Tracking/TrackShipments.php +++ b/src/API/Requests/Tracking/TrackShipments.php @@ -25,7 +25,7 @@ class TrackShipments extends API implements Normalize * @return ShipmentTrackingResponse * @throws Exception */ - public function make() + public function run() { $this->validate(); diff --git a/src/Aramex.php b/src/Aramex.php index 06bd18c..fff360a 100644 --- a/src/Aramex.php +++ b/src/Aramex.php @@ -23,90 +23,90 @@ class Aramex { // Location - public static function FetchCities() + public static function fetchCities() { return new FetchCities(); } - public static function FetchCountries() + public static function fetchCountries() { return new FetchCountries(); } - public static function FetchCountry() + public static function fetchCountry() { return new FetchCountry(); } - public static function FetchDropOffLocations() + public static function fetchDropOffLocations() { return new FetchDropOffLocations(); } - public static function FetchOffices() + public static function fetchOffices() { return new FetchOffices(); } - public static function FetchStates() + public static function fetchStates() { return new FetchStates(); } - public static function ValidateAddress() + public static function validateAddress() { return new ValidateAddress(); } // Rate - public static function CalculateRate() + public static function calculateRate() { return new CalculateRate(); } // Shipping - public static function CancelPickup() + public static function cancelPickup() { return new CancelPickup(); } - public static function CreatePickup() + public static function createPickup() { return new CreatePickup(); } - public static function CreateShipments() + public static function createShipments() { return new CreateShipments(); } - public static function GetLastShipmentsNumbersRange() + public static function getLastShipmentsNumbersRange() { return new GetLastShipmentsNumbersRange(); } - public static function PrintLabel() + public static function printLabel() { return new PrintLabel(); } - public static function ReserveShipmentNumberRange() + public static function reserveShipmentNumberRange() { return new ReserveShipmentNumberRange(); } - public static function ScheduleDelivery() + public static function scheduleDelivery() { return new ScheduleDelivery(); } // Tracking - public static function TrackPickup() + public static function trackPickup() { return new TrackPickup(); } - public static function TrackShipments() + public static function trackShipments() { return new TrackShipments(); } diff --git a/src/AramexFacade.php b/src/AramexFacade.php new file mode 100644 index 0000000..59217fb --- /dev/null +++ b/src/AramexFacade.php @@ -0,0 +1,57 @@ +