From 98e6c78d32c62f8aeec3b207c1c46af7f3bbf515 Mon Sep 17 00:00:00 2001 From: Ismail Ashour Date: Fri, 8 Nov 2019 01:29:08 +0200 Subject: [PATCH 1/4] Change Description & authors --- composer.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 857042b..3c00625 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,14 @@ { "name": "extremesa/aramex", - "description": "", + "description": "Integrate Laravel project with Aramex.", "keywords": [ ], + "authors": [ + { + "name": "Ismail Ashour", + "email": "iashour@extreme.sa" + } + ], "license": "MIT", "require": { "php": ">=7.1.0", From b6c2f97a5bcd8f3c3ccb16f524d80fd747c0b7aa Mon Sep 17 00:00:00 2001 From: Ismail Ashour Date: Fri, 8 Nov 2019 10:01:59 +0200 Subject: [PATCH 2/4] Finish enhance-fix-php-docs --- src/API/Classes/Office.php | 9 ++ src/API/Classes/TrackingResult.php | 3 +- src/API/Requests/Location/FetchCities.php | 4 + src/API/Requests/Location/FetchCountries.php | 1 + src/API/Requests/Location/FetchCountry.php | 4 +- src/API/Requests/Location/FetchOffices.php | 4 +- src/API/Requests/Location/FetchStates.php | 4 +- src/API/Requests/Location/ValidateAddress.php | 5 +- src/API/Requests/Rate/CalculateRate.php | 10 +- src/API/Requests/Shipping/CancelPickup.php | 2 +- src/API/Requests/Shipping/CreatePickup.php | 10 +- src/API/Requests/Shipping/CreateShipments.php | 14 +-- .../Shipping/GetLastShipmentsNumbersRange.php | 8 +- src/API/Requests/Shipping/PrintLabel.php | 2 +- .../Shipping/ReserveShipmentNumberRange.php | 8 +- .../Requests/Shipping/ScheduleDelivery.php | 56 +++++------ src/API/Requests/Shipping/Shipping.php | 95 ------------------- src/API/Requests/Tracking/TrackPickup.php | 10 +- src/API/Requests/Tracking/TrackShipments.php | 8 +- .../Location/AddressValidationResponse.php | 4 +- .../Location/CitiesFetchingResponse.php | 2 +- .../Location/CountriesFetchingResponse.php | 4 +- .../Location/CountryFetchingResponse.php | 6 +- .../DropOffLocationsFetchingResponse.php | 16 +--- .../Location/OfficesFetchingResponse.php | 3 +- .../Location/StatesFetchingResponse.php | 2 +- .../Response/Rate/RateCalculatorResponse.php | 2 +- .../Shipping/PickupCancellationResponse.php | 3 +- .../Tracking/PickupTrackingResponse.php | 15 ++- .../Tracking/ShipmentTrackingResponse.php | 2 +- src/Aramex.php | 2 +- 31 files changed, 129 insertions(+), 189 deletions(-) delete mode 100644 src/API/Requests/Shipping/Shipping.php diff --git a/src/API/Classes/Office.php b/src/API/Classes/Office.php index ea97068..1be3238 100644 --- a/src/API/Classes/Office.php +++ b/src/API/Classes/Office.php @@ -33,6 +33,7 @@ public function getEntity(): string /** * @param string $entity + * @return Office */ public function setEntity(string $entity): Office { @@ -50,6 +51,7 @@ public function getEntityDescription(): string /** * @param string $entityDescription + * @return Office */ public function setEntityDescription(string $entityDescription): Office { @@ -67,6 +69,7 @@ public function getOfficeType(): string /** * @param string $officeType + * @return Office */ public function setOfficeType(string $officeType): Office { @@ -84,6 +87,7 @@ public function getAddress(): Address /** * @param Address $address + * @return Office */ public function setAddress(Address $address): Office { @@ -101,6 +105,7 @@ public function getTelephone(): ?string /** * @param string|null $telephone + * @return Office */ public function setTelephone(?string $telephone): Office { @@ -118,6 +123,7 @@ public function getWorkingDays(): string /** * @param string $workingDays + * @return Office */ public function setWorkingDays(string $workingDays): Office { @@ -135,6 +141,7 @@ public function getWorkingHours(): string /** * @param string $workingHours + * @return Office */ public function setWorkingHours(string $workingHours): Office { @@ -152,6 +159,7 @@ public function getLongtitude(): ?float /** * @param mixed $longtitude + * @return Office */ public function setLongtitude(float $longtitude): Office { @@ -169,6 +177,7 @@ public function getLatitude(): ?float /** * @param float $latitude + * @return Office */ public function setLatitude(float $latitude): Office { diff --git a/src/API/Classes/TrackingResult.php b/src/API/Classes/TrackingResult.php index f0362b6..54b1456 100644 --- a/src/API/Classes/TrackingResult.php +++ b/src/API/Classes/TrackingResult.php @@ -205,13 +205,12 @@ public function setWeightUnit(string $weightUnit): TrackingResult /** * @param object $obj - * @return Track + * @return TrackingResult */ public static function parse($obj) { $obj = $obj->Value->TrackingResult; - return (new self()) ->setWaybillNumber($obj->WaybillNumber) ->setUpdateCode($obj->UpdateCode) diff --git a/src/API/Requests/Location/FetchCities.php b/src/API/Requests/Location/FetchCities.php index 76c11ca..2323780 100644 --- a/src/API/Requests/Location/FetchCities.php +++ b/src/API/Requests/Location/FetchCities.php @@ -25,6 +25,7 @@ class FetchCities extends API implements Normalize /** * @return CitiesFetchingResponse + * @throws \Exception */ public function fetch() { @@ -43,6 +44,7 @@ public function getCountryCode(): ?string /** * @param string $countryCode + * @return FetchCities */ public function setCountryCode(string $countryCode): FetchCities { @@ -60,6 +62,7 @@ public function getState(): ?string /** * @param string|null $state + * @return FetchCities */ public function setState(?string $state): FetchCities { @@ -77,6 +80,7 @@ public function getNameStartsWith(): ?string /** * @param string|null $nameStartsWith + * @return FetchCities */ public function setNameStartsWith(?string $nameStartsWith): FetchCities { diff --git a/src/API/Requests/Location/FetchCountries.php b/src/API/Requests/Location/FetchCountries.php index b6893f0..d6deaf7 100644 --- a/src/API/Requests/Location/FetchCountries.php +++ b/src/API/Requests/Location/FetchCountries.php @@ -13,6 +13,7 @@ class FetchCountries extends API implements Normalize /** * @return CountriesFetchingResponse + * @throws \Exception */ public function fetch() { diff --git a/src/API/Requests/Location/FetchCountry.php b/src/API/Requests/Location/FetchCountry.php index 76e2788..85feaea 100644 --- a/src/API/Requests/Location/FetchCountry.php +++ b/src/API/Requests/Location/FetchCountry.php @@ -2,10 +2,10 @@ namespace ExtremeSa\Aramex\API\Requests\Location; +use Exception; use ExtremeSa\Aramex\API\Interfaces\Normalize; use ExtremeSa\Aramex\API\Requests\API; use ExtremeSa\Aramex\API\Response\Location\CountryFetchingResponse; -use Exception; class FetchCountry extends API implements Normalize { @@ -16,6 +16,7 @@ class FetchCountry extends API implements Normalize /** * @return CountryFetchingResponse + * @throws Exception */ public function fetch() { @@ -43,6 +44,7 @@ public function getCode(): string /** * @param string $code + * @return FetchCountry */ public function setCode(string $code): FetchCountry { diff --git a/src/API/Requests/Location/FetchOffices.php b/src/API/Requests/Location/FetchOffices.php index 3ae2bf6..ae9fdab 100644 --- a/src/API/Requests/Location/FetchOffices.php +++ b/src/API/Requests/Location/FetchOffices.php @@ -2,10 +2,10 @@ namespace ExtremeSa\Aramex\API\Requests\Location; +use Exception; use ExtremeSa\Aramex\API\Interfaces\Normalize; use ExtremeSa\Aramex\API\Requests\API; use ExtremeSa\Aramex\API\Response\Location\OfficesFetchingResponse; -use Exception; /** * This method allows users to get list of the available ARAMEX offices within a certain country. @@ -23,6 +23,7 @@ class FetchOffices extends API implements Normalize /** * @return OfficesFetchingResponse + * @throws Exception */ public function fetch() { @@ -50,6 +51,7 @@ public function getCountryCode(): string /** * @param string $countryCode + * @return FetchOffices */ public function setCountryCode(string $countryCode): FetchOffices { diff --git a/src/API/Requests/Location/FetchStates.php b/src/API/Requests/Location/FetchStates.php index 8fc1e9a..8aa3ea3 100644 --- a/src/API/Requests/Location/FetchStates.php +++ b/src/API/Requests/Location/FetchStates.php @@ -2,10 +2,10 @@ namespace ExtremeSa\Aramex\API\Requests\Location; +use Exception; use ExtremeSa\Aramex\API\Interfaces\Normalize; use ExtremeSa\Aramex\API\Requests\API; use ExtremeSa\Aramex\API\Response\Location\StatesFetchingResponse; -use Exception; class FetchStates extends API implements Normalize { @@ -16,6 +16,7 @@ class FetchStates extends API implements Normalize /** * @return StatesFetchingResponse + * @throws Exception */ public function fetch() { @@ -43,6 +44,7 @@ public function getCountryCode(): string /** * @param string $countryCode + * @return FetchStates */ public function setCountryCode(string $countryCode): FetchStates { diff --git a/src/API/Requests/Location/ValidateAddress.php b/src/API/Requests/Location/ValidateAddress.php index f990c83..109d165 100644 --- a/src/API/Requests/Location/ValidateAddress.php +++ b/src/API/Requests/Location/ValidateAddress.php @@ -22,13 +22,13 @@ class ValidateAddress extends API implements Normalize private $address; /** - * @return ValidateAddress + * @return AddressValidationResponse + * @throws \Exception */ public function check() { $this->validate(); - dd($this->soapClient->ValidateAddress($this->normalize())); return AddressValidationResponse::make($this->soapClient->ValidateAddress($this->normalize())); } @@ -52,6 +52,7 @@ public function getAddress(): Address /** * @param Address $address + * @return ValidateAddress */ public function setAddress(Address $address): ValidateAddress { diff --git a/src/API/Requests/Rate/CalculateRate.php b/src/API/Requests/Rate/CalculateRate.php index 5707a69..2101708 100644 --- a/src/API/Requests/Rate/CalculateRate.php +++ b/src/API/Requests/Rate/CalculateRate.php @@ -3,6 +3,7 @@ namespace ExtremeSa\Aramex\API\Requests\Rate; +use Exception; use ExtremeSa\Aramex\API\Classes\Address; use ExtremeSa\Aramex\API\Classes\ShipmentDetails; use ExtremeSa\Aramex\API\Interfaces\Normalize; @@ -20,7 +21,8 @@ class CalculateRate extends API implements Normalize protected $test_wsdl = 'https://ws.aramex.net/ShippingAPI.V2/RateCalculator/Service_1_0.svc?wsdl'; /** - * @return RateResponse + * @return RateCalculatorResponse + * @throws Exception */ public function calculate() { @@ -34,15 +36,15 @@ protected function validate() Parent::validate(); if (!$this->originalAddress) { - throw new \Exception('Origin Address not provided'); + throw new Exception('Origin Address not provided'); } if (!$this->destinationAddress) { - throw new \Exception('Destination Address not provided'); + throw new Exception('Destination Address not provided'); } if (!$this->shipmentDetails) { - throw new \Exception('Shipment Details not provided'); + throw new Exception('Shipment Details not provided'); } } diff --git a/src/API/Requests/Shipping/CancelPickup.php b/src/API/Requests/Shipping/CancelPickup.php index 3e22190..f6cf97f 100644 --- a/src/API/Requests/Shipping/CancelPickup.php +++ b/src/API/Requests/Shipping/CancelPickup.php @@ -2,10 +2,10 @@ namespace ExtremeSa\Aramex\API\Requests\Shipping; +use Exception; use ExtremeSa\Aramex\API\Interfaces\Normalize; use ExtremeSa\Aramex\API\Requests\API; use ExtremeSa\Aramex\API\Response\Shipping\PickupCancellationResponse; -use Exception; /** * This method allows you to cancel a pickup as long as it is un-assigned or pending details. diff --git a/src/API/Requests/Shipping/CreatePickup.php b/src/API/Requests/Shipping/CreatePickup.php index f107d0d..57ca55b 100644 --- a/src/API/Requests/Shipping/CreatePickup.php +++ b/src/API/Requests/Shipping/CreatePickup.php @@ -2,12 +2,12 @@ namespace ExtremeSa\Aramex\API\Requests\Shipping; +use Exception; use ExtremeSa\Aramex\API\Classes\LabelInfo; use ExtremeSa\Aramex\API\Classes\Pickup; use ExtremeSa\Aramex\API\Interfaces\Normalize; use ExtremeSa\Aramex\API\Requests\API; use ExtremeSa\Aramex\API\Response\Shipping\PickupCreationResponse; -use Exception; /** * This method allows users to create a pickup request. @@ -45,9 +45,9 @@ public function getPickup() /** * @param Pickup $pickup - * @return $this + * @return CreatePickup */ - public function setPickup(Pickup $pickup) + public function setPickup(Pickup $pickup): CreatePickup { $this->pickup = $pickup; return $this; @@ -63,9 +63,9 @@ public function getLabelInfo() /** * @param LabelInfo $labelInfo - * @return $this + * @return CreatePickup */ - public function setLabelInfo(LabelInfo $labelInfo) + public function setLabelInfo(LabelInfo $labelInfo): CreatePickup { $this->labelInfo = $labelInfo; return $this; diff --git a/src/API/Requests/Shipping/CreateShipments.php b/src/API/Requests/Shipping/CreateShipments.php index 5f5a215..69b112b 100644 --- a/src/API/Requests/Shipping/CreateShipments.php +++ b/src/API/Requests/Shipping/CreateShipments.php @@ -2,12 +2,12 @@ namespace ExtremeSa\Aramex\API\Requests\Shipping; +use Exception; use ExtremeSa\Aramex\API\Classes\LabelInfo; use ExtremeSa\Aramex\API\Classes\Shipment; use ExtremeSa\Aramex\API\Interfaces\Normalize; use ExtremeSa\Aramex\API\Requests\API; use ExtremeSa\Aramex\API\Response\Shipping\ShipmentCreationResponse; -use Exception; /** * This method allows users to create shipments on Aramex’s system. @@ -54,9 +54,9 @@ public function getShipments() /** * @param Shipment[] $shipments - * @return $this + * @return CreateShipments */ - public function setShipments(array $shipments) + public function setShipments(array $shipments): CreateShipments { $this->shipments = $shipments; return $this; @@ -64,9 +64,9 @@ public function setShipments(array $shipments) /** * @param Shipment $shipment - * @return $this + * @return CreateShipments */ - public function addShipment(Shipment $shipment) + public function addShipment(Shipment $shipment): CreateShipments { $this->shipments[] = $shipment; return $this; @@ -82,9 +82,9 @@ public function getLabelInfo() /** * @param LabelInfo $labelInfo - * @return $this + * @return CreateShipments */ - public function setLabelInfo(LabelInfo $labelInfo) + public function setLabelInfo(LabelInfo $labelInfo): CreateShipments { $this->labelInfo = $labelInfo; return $this; diff --git a/src/API/Requests/Shipping/GetLastShipmentsNumbersRange.php b/src/API/Requests/Shipping/GetLastShipmentsNumbersRange.php index 697fe56..e462c75 100644 --- a/src/API/Requests/Shipping/GetLastShipmentsNumbersRange.php +++ b/src/API/Requests/Shipping/GetLastShipmentsNumbersRange.php @@ -2,10 +2,10 @@ namespace ExtremeSa\Aramex\API\Requests\Shipping; +use Exception; use ExtremeSa\Aramex\API\Interfaces\Normalize; use ExtremeSa\Aramex\API\Requests\API; use ExtremeSa\Aramex\API\Response\Shipping\LastReservedShipmentNumberRangeResponse; -use Exception; /** * This method allows you to inquire about the last reserved range using a specific entity and product group @@ -29,8 +29,6 @@ public function create(): LastReservedShipmentNumberRangeResponse { $this->validate(); - dd($this->soapClient->GetLastShipmentsNumbersRange($this->normalize())); - return LastReservedShipmentNumberRangeResponse::make($this->soapClient->GetLastShipmentsNumbersRange($this->normalize())); } @@ -60,7 +58,7 @@ public function getEntity(): string /** * @param string $entity - * @return LastReserveShipmentNumberRange + * @return GetLastShipmentsNumbersRange */ public function setEntity(string $entity): GetLastShipmentsNumbersRange { @@ -79,7 +77,7 @@ public function getProductGroup(): string /** * @param string $productGroup - * @return LastReserveShipmentNumberRange + * @return GetLastShipmentsNumbersRange */ public function setProductGroup(string $productGroup): GetLastShipmentsNumbersRange { diff --git a/src/API/Requests/Shipping/PrintLabel.php b/src/API/Requests/Shipping/PrintLabel.php index 18695f0..02c465c 100644 --- a/src/API/Requests/Shipping/PrintLabel.php +++ b/src/API/Requests/Shipping/PrintLabel.php @@ -2,11 +2,11 @@ namespace ExtremeSa\Aramex\API\Requests\Shipping; +use Exception; use ExtremeSa\Aramex\API\Classes\LabelInfo; use ExtremeSa\Aramex\API\Interfaces\Normalize; use ExtremeSa\Aramex\API\Requests\API; use ExtremeSa\Aramex\API\Response\Shipping\LabelPrintingResponse; -use Exception; /** * This method allows the user to print a label for an existing shipment. diff --git a/src/API/Requests/Shipping/ReserveShipmentNumberRange.php b/src/API/Requests/Shipping/ReserveShipmentNumberRange.php index 734bc38..dd03e16 100644 --- a/src/API/Requests/Shipping/ReserveShipmentNumberRange.php +++ b/src/API/Requests/Shipping/ReserveShipmentNumberRange.php @@ -2,10 +2,10 @@ namespace ExtremeSa\Aramex\API\Requests\Shipping; +use Exception; use ExtremeSa\Aramex\API\Interfaces\Normalize; use ExtremeSa\Aramex\API\Requests\API; use ExtremeSa\Aramex\API\Response\Shipping\ReserveRangeResponse; -use Exception; /** * This method allows you to reserve a range of shipment numbers. @@ -67,7 +67,7 @@ public function getEntity(): string * Example: LON for London station * * @param string $entity - * @return ReserveRange + * @return ReserveShipmentNumberRange */ public function setEntity(string $entity): ReserveShipmentNumberRange { @@ -89,7 +89,7 @@ public function getProductGroup(): string * DOM = Domestic * * @param string $productGroup - * @return ReserveRange + * @return ReserveShipmentNumberRange */ public function setProductGroup(string $productGroup): ReserveShipmentNumberRange { @@ -110,7 +110,7 @@ public function getCount(): int * Allowed Values: 1-5000 * * @param int $count - * @return ReserveRange + * @return ReserveShipmentNumberRange */ public function setCount(int $count): ReserveShipmentNumberRange { diff --git a/src/API/Requests/Shipping/ScheduleDelivery.php b/src/API/Requests/Shipping/ScheduleDelivery.php index be6f77a..53145bf 100644 --- a/src/API/Requests/Shipping/ScheduleDelivery.php +++ b/src/API/Requests/Shipping/ScheduleDelivery.php @@ -2,12 +2,12 @@ namespace ExtremeSa\Aramex\API\Requests\Shipping; +use Exception; use ExtremeSa\Aramex\API\Classes\Address; -use ExtremeSa\Aramex\API\Classes\ScheduledDelivery as Resource; +use ExtremeSa\Aramex\API\Classes\ScheduledDelivery; use ExtremeSa\Aramex\API\Interfaces\Normalize; use ExtremeSa\Aramex\API\Requests\API; -use ExtremeSa\Aramex\API\Response\ScheduledDeliveryResponse; -use Exception; +use ExtremeSa\Aramex\API\Response\Shipping\ScheduledDeliveryResponse; /** * This method allows you to schedule the delivery of a shipment at a specified time and place (Longitude and Latitude) @@ -53,27 +53,27 @@ public function getAddress(): Address /** * @param Address $address - * @return ScheduledDelivery + * @return ScheduleDelivery */ - public function setAddress(Address $address): ScheduledDelivery + public function setAddress(Address $address): ScheduleDelivery { $this->address = $address; return $this; } /** - * @return Resource + * @return ScheduledDelivery */ - public function getScheduledDelivery(): Resource + public function getScheduledDelivery(): ScheduledDelivery { return $this->scheduledDelivery; } /** - * @param mixed $scheduledDelivery - * @return ScheduledDelivery + * @param ScheduledDelivery $scheduledDelivery + * @return ScheduleDelivery */ - public function setScheduledDelivery($scheduledDelivery): ScheduledDelivery + public function setScheduledDelivery(ScheduledDelivery $scheduledDelivery): ScheduleDelivery { $this->scheduledDelivery = $scheduledDelivery; return $this; @@ -89,9 +89,9 @@ public function getShipmentNumber(): string /** * @param string $shipmentNumber - * @return ScheduledDelivery + * @return ScheduleDelivery */ - public function setShipmentNumber(string $shipmentNumber): ScheduledDelivery + public function setShipmentNumber(string $shipmentNumber): ScheduleDelivery { $this->shipmentNumber = $shipmentNumber; return $this; @@ -107,9 +107,9 @@ public function getProductGroup(): string /** * @param string $productGroup - * @return ScheduledDelivery + * @return ScheduleDelivery */ - public function setProductGroup(string $productGroup): ScheduledDelivery + public function setProductGroup(string $productGroup): ScheduleDelivery { $this->productGroup = $productGroup; return $this; @@ -125,9 +125,9 @@ public function getEntity(): string /** * @param string $entity - * @return ScheduledDelivery + * @return ScheduleDelivery */ - public function setEntity(string $entity): ScheduledDelivery + public function setEntity(string $entity): ScheduleDelivery { $this->entity = $entity; return $this; @@ -143,9 +143,9 @@ public function getConsigneePhone(): string /** * @param string $consigneePhone - * @return ScheduledDelivery + * @return ScheduleDelivery */ - public function setConsigneePhone(string $consigneePhone): ScheduledDelivery + public function setConsigneePhone(string $consigneePhone): ScheduleDelivery { $this->consigneePhone = $consigneePhone; return $this; @@ -161,9 +161,9 @@ public function getShipperNumber(): string /** * @param string $shipperNumber - * @return ScheduledDelivery + * @return ScheduleDelivery */ - public function setShipperNumber(string $shipperNumber): ScheduledDelivery + public function setShipperNumber(string $shipperNumber): ScheduleDelivery { $this->shipperNumber = $shipperNumber; return $this; @@ -179,9 +179,9 @@ public function getShipperReference(): string /** * @param string $shipperReference - * @return ScheduledDelivery + * @return ScheduleDelivery */ - public function setShipperReference(string $shipperReference): ScheduledDelivery + public function setShipperReference(string $shipperReference): ScheduleDelivery { $this->shipperReference = $shipperReference; return $this; @@ -197,9 +197,9 @@ public function getReference1(): string /** * @param string $reference1 - * @return ScheduledDelivery + * @return ScheduleDelivery */ - public function setReference1(string $reference1): ScheduledDelivery + public function setReference1(string $reference1): ScheduleDelivery { $this->reference1 = $reference1; return $this; @@ -215,9 +215,9 @@ public function getReference2(): string /** * @param string $reference2 - * @return ScheduledDelivery + * @return ScheduleDelivery */ - public function setReference2(string $reference2) + public function setReference2(string $reference2): ScheduleDelivery { $this->reference2 = $reference2; return $this; @@ -233,9 +233,9 @@ public function getReference3(): string /** * @param string $reference3 - * @return ScheduledDelivery + * @return ScheduleDelivery */ - public function setReference3(string $reference3): ScheduledDelivery + public function setReference3(string $reference3): ScheduleDelivery { $this->reference3 = $reference3; return $this; diff --git a/src/API/Requests/Shipping/Shipping.php b/src/API/Requests/Shipping/Shipping.php deleted file mode 100644 index dfbc2ef..0000000 --- a/src/API/Requests/Shipping/Shipping.php +++ /dev/null @@ -1,95 +0,0 @@ -validate(); - - return ShippingResponse::make($this->soapClient->CreateShipments($this->normalize())); - } - - protected function validate() - { - if (!sizeof($this->shipments)) { - throw new Exception('Shipments are not provided'); - } - } - - /** - * @return Shipment[] - */ - public function getShipments() - { - return $this->shipments; - } - - /** - * @param Shipment[] $shipments - * @return $this - */ - public function setShipments(array $shipments) - { - $this->shipments = $shipments; - return $this; - } - - /** - * @param Shipment $shipment - * @return $this - */ - public function addShipment(Shipment $shipment) - { - $this->shipments[] = $shipment; - return $this; - } - - /** - * @return LabelInfo|null - */ - public function getLabelInfo() - { - return $this->labelInfo; - } - - /** - * @param LabelInfo $labelInfo - * @return $this - */ - public function setLabelInfo(LabelInfo $labelInfo) - { - $this->labelInfo = $labelInfo; - return $this; - } - - public function normalize(): array - { - return array_merge([ - 'Shipments' => $this->getShipments() ? array_map(function ($item) { - return $item->normalize(); - }, $this->getShipments()) : [], - 'LabelInfo' => optional($this->getLabelInfo())->normalize(), - ], parent::normalize()); - } -} - - diff --git a/src/API/Requests/Tracking/TrackPickup.php b/src/API/Requests/Tracking/TrackPickup.php index 99f5830..f1875fb 100644 --- a/src/API/Requests/Tracking/TrackPickup.php +++ b/src/API/Requests/Tracking/TrackPickup.php @@ -2,9 +2,11 @@ namespace ExtremeSa\Aramex\API\Requests\Tracking; +use Exception; use ExtremeSa\Aramex\API\Interfaces\Normalize; use ExtremeSa\Aramex\API\Requests\API; use ExtremeSa\Aramex\API\Response\Tracking\PickupTrackingResponse; +use ExtremeSa\Aramex\API\Response\Tracking\RateResponse; class TrackPickup extends API implements Normalize { @@ -15,6 +17,10 @@ class TrackPickup extends API implements Normalize private $reference; private $pickup; + /** + * @return PickupTrackingResponse + * @throws Exception + */ public function track() { $this->validate(); @@ -25,11 +31,11 @@ public function track() protected function validate() { if (!$this->reference) { - throw new \Exception('Reference is not provided'); + throw new Exception('Reference is not provided'); } if (!$this->pickup) { - throw new \Exception('Pickup is not provided'); + throw new Exception('Pickup is not provided'); } } diff --git a/src/API/Requests/Tracking/TrackShipments.php b/src/API/Requests/Tracking/TrackShipments.php index 164162b..f7e83cc 100644 --- a/src/API/Requests/Tracking/TrackShipments.php +++ b/src/API/Requests/Tracking/TrackShipments.php @@ -2,8 +2,10 @@ namespace ExtremeSa\Aramex\API\Requests\Tracking; +use Exception; use ExtremeSa\Aramex\API\Interfaces\Normalize; use ExtremeSa\Aramex\API\Requests\API; +use ExtremeSa\Aramex\API\Response\Tracking\RateResponse; use ExtremeSa\Aramex\API\Response\Tracking\ShipmentTrackingResponse; /** @@ -20,6 +22,10 @@ class TrackShipments extends API implements Normalize private $shipments; private $getLastTrackingUpdateOnly; + /** + * @return ShipmentTrackingResponse + * @throws Exception + */ public function track() { $this->validate(); @@ -32,7 +38,7 @@ protected function validate() parent::validate(); if (!$this->shipments) { - throw new \Exception('Shipments are not provided'); + throw new Exception('Shipments are not provided'); } } diff --git a/src/API/Response/Location/AddressValidationResponse.php b/src/API/Response/Location/AddressValidationResponse.php index 45ec3a0..71a5783 100644 --- a/src/API/Response/Location/AddressValidationResponse.php +++ b/src/API/Response/Location/AddressValidationResponse.php @@ -26,6 +26,7 @@ public function getSuggestedAddresses(): array /** * @param Address[] $suggestedAddresses + * @return AddressValidationResponse */ public function setSuggestedAddresses(array $suggestedAddresses): AddressValidationResponse { @@ -35,6 +36,7 @@ public function setSuggestedAddresses(array $suggestedAddresses): AddressValidat /** * @param Address $suggestedAddresses + * @return AddressValidationResponse */ public function addSuggestedAddresses(Address $suggestedAddress): AddressValidationResponse { @@ -58,7 +60,7 @@ protected function parse($obj) /** * @param object $obj - * @return RateResponse + * @return AddressValidationResponse */ public static function make($obj) { diff --git a/src/API/Response/Location/CitiesFetchingResponse.php b/src/API/Response/Location/CitiesFetchingResponse.php index e33a4f6..3de6906 100644 --- a/src/API/Response/Location/CitiesFetchingResponse.php +++ b/src/API/Response/Location/CitiesFetchingResponse.php @@ -56,7 +56,7 @@ protected function parse($obj) /** * @param object $obj - * @return RateResponse + * @return CitiesFetchingResponse */ public static function make($obj) { diff --git a/src/API/Response/Location/CountriesFetchingResponse.php b/src/API/Response/Location/CountriesFetchingResponse.php index a6b8cf3..a0104f9 100644 --- a/src/API/Response/Location/CountriesFetchingResponse.php +++ b/src/API/Response/Location/CountriesFetchingResponse.php @@ -10,7 +10,7 @@ class CountriesFetchingResponse extends Response private $countries; /** - * @return Country + * @return Country[] */ public function getCountries(): array { @@ -64,7 +64,7 @@ protected function parse($obj) /** * @param object $obj - * @return RateResponse + * @return CountriesFetchingResponse */ public static function make($obj) { diff --git a/src/API/Response/Location/CountryFetchingResponse.php b/src/API/Response/Location/CountryFetchingResponse.php index 4cd41f8..4b45855 100644 --- a/src/API/Response/Location/CountryFetchingResponse.php +++ b/src/API/Response/Location/CountryFetchingResponse.php @@ -10,7 +10,7 @@ class CountryFetchingResponse extends Response private $country; /** - * @return Country + * @return array */ public function getCountry(): array { @@ -35,7 +35,7 @@ protected function parse($obj) { parent::parse($obj); - if ($country = $obj->Country){ + if ($country = $obj->Country) { $this->setCountry( (new Country()) ->setCode($country->Code) @@ -52,7 +52,7 @@ protected function parse($obj) /** * @param object $obj - * @return RateResponse + * @return CountryFetchingResponse */ public static function make($obj) { diff --git a/src/API/Response/Location/DropOffLocationsFetchingResponse.php b/src/API/Response/Location/DropOffLocationsFetchingResponse.php index ee90061..e15e05e 100644 --- a/src/API/Response/Location/DropOffLocationsFetchingResponse.php +++ b/src/API/Response/Location/DropOffLocationsFetchingResponse.php @@ -26,9 +26,9 @@ public function getOffices(): array /** * @param Office[] $offices - * @return $this + * @return DropOffLocationsFetchingResponse */ - public function setOffices(array $offices): OfficesFetchingResponse + public function setOffices(array $offices): DropOffLocationsFetchingResponse { $this->offices = $offices; return $this; @@ -36,9 +36,9 @@ public function setOffices(array $offices): OfficesFetchingResponse /** * @param Office $office - * @return $this + * @return DropOffLocationsFetchingResponse */ - public function addOffice(Office $office): OfficesFetchingResponse + public function addOffice(Office $office): DropOffLocationsFetchingResponse { $this->offices[] = $office; return $this; @@ -57,12 +57,6 @@ protected function parse($obj) foreach ($obj->Locations->DropOffLocation as $office) { $this->addOffice( (new Office()) - ->setCode($office->ID) - ->setName($office->Description) - ->setIsoCode($office->Address) - ->setStateRequired($office->Telephone) - ->setPostCodeRequired($office->WorkingDays) - ->setInternationalCallingNumber($office->WorkingHours) ); } } @@ -72,7 +66,7 @@ protected function parse($obj) /** * @param object $obj - * @return RateResponse + * @return DropOffLocationsFetchingResponse */ public static function make($obj) { diff --git a/src/API/Response/Location/OfficesFetchingResponse.php b/src/API/Response/Location/OfficesFetchingResponse.php index 30a09f4..9dcd9b3 100644 --- a/src/API/Response/Location/OfficesFetchingResponse.php +++ b/src/API/Response/Location/OfficesFetchingResponse.php @@ -92,7 +92,6 @@ protected function parse($obj) } } - dd($this->offices); return $this; } @@ -108,7 +107,7 @@ public function objectToObject($instance, $className) /** * @param object $obj - * @return RateResponse + * @return OfficesFetchingResponse */ public static function make($obj) { diff --git a/src/API/Response/Location/StatesFetchingResponse.php b/src/API/Response/Location/StatesFetchingResponse.php index 054101b..790dc1d 100644 --- a/src/API/Response/Location/StatesFetchingResponse.php +++ b/src/API/Response/Location/StatesFetchingResponse.php @@ -62,7 +62,7 @@ protected function parse($obj) /** * @param object $obj - * @return RateResponse + * @return StatesFetchingResponse */ public static function make($obj) { diff --git a/src/API/Response/Rate/RateCalculatorResponse.php b/src/API/Response/Rate/RateCalculatorResponse.php index a71b3f1..a075d9a 100644 --- a/src/API/Response/Rate/RateCalculatorResponse.php +++ b/src/API/Response/Rate/RateCalculatorResponse.php @@ -42,7 +42,7 @@ protected function parse($obj) /** * @param object $obj - * @return RateResponse + * @return RateCalculatorResponse */ public static function make($obj) { diff --git a/src/API/Response/Shipping/PickupCancellationResponse.php b/src/API/Response/Shipping/PickupCancellationResponse.php index 7681222..ca7f5ae 100644 --- a/src/API/Response/Shipping/PickupCancellationResponse.php +++ b/src/API/Response/Shipping/PickupCancellationResponse.php @@ -24,6 +24,7 @@ public function getMessage(): string /** * @param string $message + * @return PickupCancellationResponse */ public function setMessage(string $message): PickupCancellationResponse { @@ -35,7 +36,7 @@ public function setMessage(string $message): PickupCancellationResponse * @param object $obj * @return self */ - protected function parse($obj) + protected function parse($obj): PickupCancellationResponse { parent::parse($obj); diff --git a/src/API/Response/Tracking/PickupTrackingResponse.php b/src/API/Response/Tracking/PickupTrackingResponse.php index eb4f896..9eab48c 100644 --- a/src/API/Response/Tracking/PickupTrackingResponse.php +++ b/src/API/Response/Tracking/PickupTrackingResponse.php @@ -24,6 +24,7 @@ public function getEntity(): string /** * @param string $entity + * @return PickupTrackingResponse */ public function setEntity($entity): PickupTrackingResponse { @@ -41,6 +42,7 @@ public function getReference(): string /** * @param string $reference + * @return PickupTrackingResponse */ public function setReference($reference): PickupTrackingResponse { @@ -58,6 +60,7 @@ public function getCollectionDate(): string /** * @param string $collectionDate + * @return PickupTrackingResponse */ public function setCollectionDate($collectionDate): PickupTrackingResponse { @@ -75,6 +78,7 @@ public function getPickupDate(): string /** * @param string $pickupDate + * @return PickupTrackingResponse */ public function setPickupDate($pickupDate): PickupTrackingResponse { @@ -92,6 +96,7 @@ public function getLastStatus(): string /** * @param string $lastStatus + * @return PickupTrackingResponse */ public function setLastStatus($lastStatus): PickupTrackingResponse { @@ -109,6 +114,7 @@ public function getLastStatusDescription(): string /** * @param string $lastStatusDescription + * @return PickupTrackingResponse */ public function setLastStatusDescription($lastStatusDescription): PickupTrackingResponse { @@ -126,6 +132,7 @@ public function getCollectedWaybills(): string /** * @param string $collectedWaybills + * @return PickupTrackingResponse */ public function setCollectedWaybills($collectedWaybills): PickupTrackingResponse { @@ -135,9 +142,9 @@ public function setCollectedWaybills($collectedWaybills): PickupTrackingResponse /** * @param object $obj - * @return self + * @return PickupTrackingResponse */ - protected function parse($obj) + protected function parse($obj): PickupTrackingResponse { parent::parse($obj); @@ -155,9 +162,9 @@ protected function parse($obj) /** * @param object $obj - * @return RateResponse + * @return PickupTrackingResponse */ - public static function make($obj) + public static function make($obj): PickupTrackingResponse { return (new self())->parse($obj); } diff --git a/src/API/Response/Tracking/ShipmentTrackingResponse.php b/src/API/Response/Tracking/ShipmentTrackingResponse.php index 7073209..50a58bb 100644 --- a/src/API/Response/Tracking/ShipmentTrackingResponse.php +++ b/src/API/Response/Tracking/ShipmentTrackingResponse.php @@ -54,7 +54,7 @@ protected function parse($obj) /** * @param object $obj - * @return RateResponse + * @return ShipmentTrackingResponse */ public static function make($obj) { diff --git a/src/Aramex.php b/src/Aramex.php index 6b2f3d6..06bd18c 100644 --- a/src/Aramex.php +++ b/src/Aramex.php @@ -100,7 +100,7 @@ public static function ScheduleDelivery() return new ScheduleDelivery(); } - // Traching + // Tracking public static function TrackPickup() { return new TrackPickup(); From 1a87ac6c2d3a67f7fa49860e2f0f89fab86c4488 Mon Sep 17 00:00:00 2001 From: Ismail Ashour Date: Fri, 8 Nov 2019 10:53:50 +0200 Subject: [PATCH 3/4] Finish fix-calculate-rate-in-live-environment --- src/API/Requests/API.php | 10 ++- src/API/Requests/Rate/CalculateRate.php | 5 ++ src/API/Requests/Shipping/Shipping.php | 95 +++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 src/API/Requests/Shipping/Shipping.php diff --git a/src/API/Requests/API.php b/src/API/Requests/API.php index 43ed5a4..2937d3e 100644 --- a/src/API/Requests/API.php +++ b/src/API/Requests/API.php @@ -20,9 +20,15 @@ abstract class API implements Normalize protected $live_wsdl; protected $environment; - public function __construct() + public function __construct($environment = null) { - config('aramex.mode') === 'live' ? $this->useLiveAsEnvironment() : $this->useTestAsEnvironment(); + if ($environment) { + $this->setEnvironment($environment); + } else { + config('aramex.mode') === 'live' ? $this->useLiveAsEnvironment() : $this->useTestAsEnvironment(); + } + + dd($this->environment); $this->fillClientInfoFromEnv(); diff --git a/src/API/Requests/Rate/CalculateRate.php b/src/API/Requests/Rate/CalculateRate.php index 2101708..75eef41 100644 --- a/src/API/Requests/Rate/CalculateRate.php +++ b/src/API/Requests/Rate/CalculateRate.php @@ -20,6 +20,11 @@ class CalculateRate extends API implements Normalize protected $live_wsdl = 'https://ws.aramex.net/ShippingAPI.V2/RateCalculator/Service_1_0.svc?wsdl'; protected $test_wsdl = 'https://ws.aramex.net/ShippingAPI.V2/RateCalculator/Service_1_0.svc?wsdl'; + public function __construct() + { + parent::__construct('live'); + } + /** * @return RateCalculatorResponse * @throws Exception diff --git a/src/API/Requests/Shipping/Shipping.php b/src/API/Requests/Shipping/Shipping.php new file mode 100644 index 0000000..dfbc2ef --- /dev/null +++ b/src/API/Requests/Shipping/Shipping.php @@ -0,0 +1,95 @@ +validate(); + + return ShippingResponse::make($this->soapClient->CreateShipments($this->normalize())); + } + + protected function validate() + { + if (!sizeof($this->shipments)) { + throw new Exception('Shipments are not provided'); + } + } + + /** + * @return Shipment[] + */ + public function getShipments() + { + return $this->shipments; + } + + /** + * @param Shipment[] $shipments + * @return $this + */ + public function setShipments(array $shipments) + { + $this->shipments = $shipments; + return $this; + } + + /** + * @param Shipment $shipment + * @return $this + */ + public function addShipment(Shipment $shipment) + { + $this->shipments[] = $shipment; + return $this; + } + + /** + * @return LabelInfo|null + */ + public function getLabelInfo() + { + return $this->labelInfo; + } + + /** + * @param LabelInfo $labelInfo + * @return $this + */ + public function setLabelInfo(LabelInfo $labelInfo) + { + $this->labelInfo = $labelInfo; + return $this; + } + + public function normalize(): array + { + return array_merge([ + 'Shipments' => $this->getShipments() ? array_map(function ($item) { + return $item->normalize(); + }, $this->getShipments()) : [], + 'LabelInfo' => optional($this->getLabelInfo())->normalize(), + ], parent::normalize()); + } +} + + From ce8191292ac893fb0e48e7393e45fd6850911581 Mon Sep 17 00:00:00 2001 From: Ismail Ashour Date: Fri, 8 Nov 2019 10:54:17 +0200 Subject: [PATCH 4/4] Finish enhance-fix-php-docs --- src/API/Requests/Shipping/Shipping.php | 95 -------------------------- 1 file changed, 95 deletions(-) delete mode 100644 src/API/Requests/Shipping/Shipping.php diff --git a/src/API/Requests/Shipping/Shipping.php b/src/API/Requests/Shipping/Shipping.php deleted file mode 100644 index dfbc2ef..0000000 --- a/src/API/Requests/Shipping/Shipping.php +++ /dev/null @@ -1,95 +0,0 @@ -validate(); - - return ShippingResponse::make($this->soapClient->CreateShipments($this->normalize())); - } - - protected function validate() - { - if (!sizeof($this->shipments)) { - throw new Exception('Shipments are not provided'); - } - } - - /** - * @return Shipment[] - */ - public function getShipments() - { - return $this->shipments; - } - - /** - * @param Shipment[] $shipments - * @return $this - */ - public function setShipments(array $shipments) - { - $this->shipments = $shipments; - return $this; - } - - /** - * @param Shipment $shipment - * @return $this - */ - public function addShipment(Shipment $shipment) - { - $this->shipments[] = $shipment; - return $this; - } - - /** - * @return LabelInfo|null - */ - public function getLabelInfo() - { - return $this->labelInfo; - } - - /** - * @param LabelInfo $labelInfo - * @return $this - */ - public function setLabelInfo(LabelInfo $labelInfo) - { - $this->labelInfo = $labelInfo; - return $this; - } - - public function normalize(): array - { - return array_merge([ - 'Shipments' => $this->getShipments() ? array_map(function ($item) { - return $item->normalize(); - }, $this->getShipments()) : [], - 'LabelInfo' => optional($this->getLabelInfo())->normalize(), - ], parent::normalize()); - } -} - -