diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0a6dd3e --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/vendor +/.idea +composer.lock +package-lock.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..f2c79e2 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Laravel Aramex. + diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..857042b --- /dev/null +++ b/composer.json @@ -0,0 +1,28 @@ +{ + "name": "extremesa/aramex", + "description": "", + "keywords": [ + ], + "license": "MIT", + "require": { + "php": ">=7.1.0", + "laravel/framework": "^5.8" + }, + "autoload": { + "psr-4": { + "ExtremeSa\\Aramex\\": "src/" + } + }, + "extra": { + "laravel": { + "providers": [ + "ExtremeSa\\Aramex\\AramexServiceProvider" + ] + } + }, + "config": { + "sort-packages": true + }, + "minimum-stability": "dev", + "prefer-stable": true +} diff --git a/config/aramex.php b/config/aramex.php new file mode 100644 index 0000000..dc3e0bc --- /dev/null +++ b/config/aramex.php @@ -0,0 +1,59 @@ + env('ARAMEX_MODE', 'test'), + + 'test' => [ + 'country_code' => '', + 'entity' => '', + 'number' => '', + 'pin' => '', + 'username' => '', + 'password' => '' + ], + 'live' => [ + 'country_code' => env('ARAMEX_COUNTRY_CODE'), + 'entity' => env('ARAMEX_ENTITY'), + 'number' => env('ARAMEX_NUMBER'), + 'pin' => env('ARAMEX_PIN'), + 'username' => env('ARAMEX_USERNAME'), + 'password' => env('ARAMEX_PASSWORD'), + ], + + 'shipper' => [ + 'name' => '', + 'email' => '', + 'mobile' => '', + 'company' => '', + 'address' => [ + 'line1' => '', + 'line2' => ' ', + 'post_code' => '', + 'city' => '', + 'country_code' => '', + 'state_or_province_code' => '' + ] + ], + + 'third_party' => [ + 'name' => '', + 'email' => '', + 'mobile' => '', + 'company' => '', + 'address' => [ + 'line1' => '', + 'line2' => '', + 'post_code' => '', + 'city' => '', + 'country_code' => '', //should be same account country code + 'state_or_province_code' => '' + ] + ], + + 'kit' => [ + 'height' => '', + 'width' => '', + 'length' => '', + 'weight' => '' + ] +]; diff --git a/resources/lang/en/en.php b/resources/lang/en/en.php new file mode 100644 index 0000000..7f453ac --- /dev/null +++ b/resources/lang/en/en.php @@ -0,0 +1,159 @@ + 'Under processing at operations facility', + 'SH003' => 'Out for Delivery', + 'SH004' => 'Out for Delivery - Partial', + 'SH005' => 'Delivered', + 'SH006' => 'Collected by Consignee', + 'SH007' => 'Will be Delivered by Postal Services', + 'SH008' => 'Shipment on Hold', + 'SH012' => 'Picked Up From Shipper', + 'SH014' => 'Record created.', + 'SH022' => 'Departed Operations facility – In Transit', + 'SH033' => 'Attempted Delivery - Consignee Rejected the Shipment Due to Delay / Awaiting Shipper Instructions', + 'SH034' => 'Documents Delivered to Consignee/Broker for Self Clearance & Delivery', + 'SH035' => 'Awaiting Clearance from Consignee/Broker to Arrange Delivery', + 'SH041' => 'Cleared from Customs', + 'SH043' => 'Invalid Identity proof document', + 'SH044' => 'Delay - Delivery Rescheduled', + 'SH047' => 'Received at Origin Facility', + 'SH069' => 'Returned to Shipper', + 'SH070' => 'Redirected to New Delivery Address', + 'SH071' => 'Please Contact Local Office to Verify Your Shipment Status', + 'SH073' => 'Shipment Forwarded to Beyond/Remote Area Sorting Location', + 'SH074' => 'Delay - Pending Payment', + 'SH076' => 'Delay - Delivery Rescheduled', + 'SH077' => 'Forwarded to Aramex office', + 'SH110' => 'Forwarded to Delivery Office', + 'SH154' => 'Delivered - Partial Delivery', + 'SH156' => 'Held - Pending KYC Document', + 'SH157' => 'Delay - Unable to Deliver', + 'SH158' => 'Held in Customs - Pending Clearance', + 'SH160' => 'Under processing at operations facility', + 'SH162' => 'Delay - Uncontrollable Due to Carrier', + 'SH163' => 'On Hold - Pending Customs Value Confirmation', + 'SH164' => 'Held for Consignee Pickup', + 'SH203' => 'Record Created', + 'SH222' => 'Arrived at Destination and Documents Recovered', + 'SH228' => 'Shipment Consol Update', + 'SH230' => 'Consignee/Broker Notified of Shipment Arrival', + 'SH234' => 'Shipment is Delivered in Letter Box', + 'SH236' => 'Document delivered.', + 'SH237' => 'Please Contact Local Office to Verify Your Shipment Status', + 'SH247' => 'Supporting Document Returned to Shipper', + 'SH249' => 'SMS Sent to Consignee to Contact Aramex and Set Delivery Address', + 'SH250' => 'Shipper Contacted', + 'SH251' => 'Third Party Customer Contacted', + 'SH252' => 'Shipment Forwarded to Beyond/Remote Area Sorting Location', + 'SH257' => 'Unable to Notify Consignee/Broker', + 'SH259' => 'Entry into Warehouse', + 'SH260' => 'Exit from Warehouse', + 'SH261' => '"Consignee contacted to set delivery', + 'SH270' => 'Email Sent to Consignee', + 'SH271' => 'SMS Sent to Consignee', + 'SH272' => 'Forwarded to Final Destination', + 'SH273' => 'Delivery Scheduled', + 'SH275' => 'On Hold - Operations Facility', + 'SH278' => 'Data received.', + 'SH279' => 'Shop&Ship Update', + 'SH280' => 'Confiscated by Customs Authorities', + 'SH281' => 'Customs\' Documents Out for Delivery', + 'SH294' => 'On Hold - Customer Mobile Cannot be Reached', + 'SH295' => 'Delivery Address Corrected', + 'SH296' => 'Delivery Address Corrected', + 'SH299' => 'Shipment Not Received from Shipper', + 'SH308' => 'Pickup Scheduled', + 'SH312' => 'Pickup Re-Scheduled', + 'SH313' => 'Pickup Cancelled', + 'SH314' => 'Pickup Completed', + 'SH369' => 'SMS Sent to Consignee', + 'SH375' => 'On Hold - Awaiting Correct Delivery Address', + 'SH376' => 'Delay - Delivery Rescheduled for Next Business Day', + 'SH381' => 'Shipment On-Hold', + 'SH382' => 'Shipment Update', + 'SH383' => 'Credit Card Payment - Completed', + 'SH406' => 'Received at Origin Facility', + 'SH407' => 'Returned to Shipper', + 'SH408' => 'Document delivered.', + 'SH410' => 'Customer contact Attempts Completed', + 'SH434' => 'Received at Origin Facility', + 'SH438' => 'Shipment transferred to other vessel', + 'SH442' => 'Booking Received from client', + 'SH443' => 'Booking Request created', + 'SH444' => 'Booking Request sent to carrier', + 'SH445' => 'Equipment release received', + 'SH446' => 'B/L Instructions Created/Sent to carrier', + 'SH447' => 'B/L Instructions sent to carrier', + 'SH448' => 'Shipment pickup arranged', + 'SH449' => 'Commercial documents is been received', + 'SH450' => 'Export Customs clearance completed', + 'SH451' => 'Shipment released to carrier / Co-loader', + 'SH452' => 'Shipment gated in', + 'SH453' => 'Vessel Delayed', + 'SH454' => 'Vessel arrived', + 'SH455' => 'Shipment short shipped / partial shipment received', + 'SH456' => 'Customer notified', + 'SH457' => 'Shipment Customer update', + 'SH458' => 'Shipment Customer update', + 'SH459' => 'Delivery order released', + 'SH460' => 'On-carriage arranged', + 'SH461' => 'Shipment in transit to final destination', + 'SH462' => 'Held by Customs', + 'SH463' => 'Shipment Customer update', + 'SH464' => 'Customs Cleared', + 'SH465' => 'Sailing reschduled- Please contact local office', + 'SH466' => 'Shipment under customs clearance process', + 'SH467' => 'Held in Customs - Awaiting Customer Instructions', + 'SH468' => 'Held in Customs - Awaiting Commercial Invoice/Clearance Documents', + 'SH469' => 'Customs Clearance - In Progress', + 'SH470' => 'Held in Customs - Awaiting Duty and Tax Payment', + 'SH471' => 'Held in Customs - Misdeclaration by Shipper / Urgent Customer Instructions Required', + 'SH472' => 'Held in Customs - Unacceptable Commodities', + 'SH473' => 'Held in Customs - Requires Governmental Approvals', + 'SH474' => 'To be Returned to Shipper', + 'SH475' => 'Forwarded to Aramex office', + 'SH479' => 'Unable to Notify Consignee/Broker', + 'SH480' => 'On Hold - Payment not Ready / Delivery Rescheduled', + 'SH484' => 'Shipment Delivery Method Set as Aramex Locker', + 'SH491' => 'SMS Reminder Sent to Pick up Shipment from Aramex Locker', + 'SH492' => 'Consignee Pickup Time Exceeded - Shipment is no Longer Available at Aramex Locker', + 'SH493' => 'Delivery Method Changed - Shipment will be Moved from Aramex Locker', + 'SH494' => 'Shipment Picked up by Aramex Courier from Locker', + 'SH495' => 'Shipment Scanned at Operations Facility', + 'SH496' => 'Shipment Picked up by Consignee', + 'SH498' => 'Customer Contact Attempts Completed - Pending Return to Shipper', + 'SH499' => 'Shipment Held at Aramex Locker for Consignee Pick up', + 'SH504' => 'Delivery Method Changed - Shipment is Oversize', + 'SH505' => 'Auto-Payment Cancelled', + 'SH513' => 'Shipment Delivery Auto-scheduled', + 'SH515' => 'Courier Called Customer – Number Unreachable', + 'SH516' => 'Customer Called Courier - Responded', + 'SH517' => 'Trip Request Created', + 'SH518' => 'Tools Ready for Shipping', + 'SH519' => 'Destination GL Provided', + 'SH521' => 'Upon Consignee Request At Local Office - Shipment To Be Scheduled For Delivery', + 'SH529' => 'Shipment Delivery Method Set as Drop-off', + 'SH530' => 'SMS Reminder Sent to Pick up Shipment from the Drop-off location', + 'SH531' => 'Consignee Pickup Time Exceeded - Shipment is no Longer Available at the Drop-off location', + 'SH532' => 'Shipment dropped off by the courier at the drop off location as per customer request', + 'SH533' => 'Shipment Held at the Drop off location for Consignee Pick up', + 'SH534' => 'Shipment Picked up from the Drop-off location', + 'SH537' => 'Shipment Delivery Method Set as Park and Parcel', + 'SH538' => 'Delivery Review – Please contact Local Office for Shipment Status', + 'SH539' => 'Delivery Review – Please contact Local Office for Shipment Status', + 'SH540' => 'Shipment arrived / Clearance In Progress', + 'SH542' => 'Clearance Process Pending- Requires Value Verification / Urgent Customer Instructions Required', + 'SH543' => 'Clearance Completed/ Awaiting gate pass', + 'SH544' => 'Clearance Process Pending- Incomplete Information / Urgent Customer Instructions Required', + 'SH546' => 'Clearance Process Pending- Incomplete Information / Urgent Customer Instructions Required', + 'SH547' => 'Clearance Process Pending- Incomplete Information / Urgent Customer Instructions Required', + 'SH548' => 'Clearance In Progress', + 'SH549' => 'Clearance In Progress- Awaiting Duty and Tax Payment', + 'SH556' => 'Customer Contacted Successfully', + 'SH559' => 'Shipment Returned to Shipper', + 'SH560' => 'Awaiting Customer Collection-Will Be Returned In 2 Days', + 'SH562' => 'Customer Approved SNS Shipment E-Invoice Goods Value', + 'SH563' => 'Customer Approved SNS Shipment Goods Value- No E-Invoice', + 'SH570' => '', +]; \ No newline at end of file diff --git a/src/API/Classes/Address.php b/src/API/Classes/Address.php new file mode 100644 index 0000000..ed78d5d --- /dev/null +++ b/src/API/Classes/Address.php @@ -0,0 +1,343 @@ +line1; + } + + /** + * Additional Address information, such as the building number, block, street name. + * More than 3 characters + * + * @param string $line1 + * @return $this + */ + public function setLine1(string $line1) + { + $this->line1 = $line1; + return $this; + } + + /** + * @return string + */ + public function getLine2(): ?string + { + return $this->line2; + } + + /** + * Additional Address information. + * + * @param string $line2 + * @return $this + */ + public function setLine2(string $line2 = null) + { + $this->line2 = $line2; + return $this; + } + + /** + * @return string + */ + public function getLine3(): ?string + { + return $this->line3; + } + + /** + * Additional Address information. + * + * @param string $line3 + * @return $this + */ + public function setLine3(string $line3 = null) + { + $this->line3 = $line3; + return $this; + } + + /** + * Address City. Conditional: Required if the post code is not given. + * + * @return string + */ + public function getCity(): ?string + { + return $this->city; + } + + /** + * Address City. + * Conditional: Required if the post code is not given. + * + * @param string $city + * @return $this + */ + public function setCity(string $city) + { + $this->city = $city; + return $this; + } + + /** + * @return string + */ + public function getStateOrProvinceCode(): ?string + { + return $this->stateOrProvinceCode; + } + + /** + * Address State or province code. + * Required if The country code and city require a State or Province Code + * + * @param string $stateOrProvinceCode + * @return $this + */ + public function setStateOrProvinceCode(string $stateOrProvinceCode = null) + { + $this->stateOrProvinceCode = $stateOrProvinceCode; + return $this; + } + + /** + * @return string + */ + public function getPostCode(): ?string + { + return $this->postCode; + } + + /** + * Postal Code, if there is a postal code in the country code and city then it must be given. + * If there are multiple cities for the same post code, the list of cities will be returned in the response. + * + * @param string $postCode + * @return $this + */ + public function setPostCode(string $postCode = null) + { + $this->postCode = $postCode; + return $this; + } + + /** + * @return string + */ + public function getCountryCode(): string + { + return $this->countryCode; + } + + /** + * 2-Letter Standard ISO Country Code. + * + * @param string $countryCode + * @return $this + */ + public function setCountryCode(string $countryCode) + { + $this->countryCode = $countryCode; + return $this; + } + + /** + * @return float + */ + public function getLongitude(): ?float + { + return $this->longitude; + } + + /** + * @param float $longitude + * @return $this + */ + public function setLongitude(float $longitude) + { + $this->longitude = $longitude; + return $this; + } + + /** + * @return float + */ + public function getLatitude(): ?float + { + return $this->latitude; + } + + /** + * @param float $latitude + * @return $this + */ + public function setLatitude(float $latitude) + { + $this->latitude = $latitude; + return $this; + } + + /** + * @return string + */ + public function getBuildingNumber(): ?string + { + return $this->buildingNumber; + } + + /** + * @param string|null $buildingNumber + * @return $this + */ + public function setBuildingNumber(string $buildingNumber = null) + { + $this->buildingNumber = $buildingNumber; + return $this; + } + + /** + * @return string + */ + public function getBuildingName(): ?string + { + return $this->buildingName; + } + + /** + * @param string|null $buildingName + * @return $this + */ + public function setBuildingName(string $buildingName = null) + { + $this->buildingName = $buildingName; + return $this; + } + + /** + * @return int + */ + public function getFloor(): ?int + { + return $this->floor; + } + + /** + * @param int|null $floor + * @return $this + */ + public function setFloor(int $floor = null) + { + $this->floor = $floor; + return $this; + } + + /** + * @return string + */ + public function getApartment(): ?string + { + return $this->apartment; + } + + /** + * /** + * @param string|null $apartment + * @return $this + */ + public function setApartment(string $apartment = null) + { + $this->apartment = $apartment; + return $this; + } + + /** + * @return string + */ + public function getPoBox(): ?string + { + return $this->poBox; + } + + /** + * @param string $poBox + * @return $this + */ + public function setPoBox(string $poBox = null) + { + $this->poBox = $poBox; + return $this; + } + + /** + * @return string + */ + public function getDescription(): ?string + { + return $this->description; + } + + /** + * @param string $description + * @return $this + */ + public function setDescription(string $description = null) + { + $this->description = $description; + return $this; + } + + public function normalize(): array + { + return [ + 'Line1' => $this->getLine1(), + 'Line2' => $this->getLine2(), + 'Line3' => $this->getLine3(), + 'City' => $this->getCity(), + 'StateOrProvinceCode' => $this->getStateOrProvinceCode(), + 'PostCode' => $this->getPostCode(), + 'CountryCode' => $this->getCountryCode(), + 'Longitude' => $this->getLongitude(), + 'Latitude' => $this->getLatitude(), + 'BuildingNumber' => $this->getBuildingNumber(), + 'BuildingName' => $this->getBuildingName(), + 'POBox' => $this->getPoBox(), + 'Description' => $this->getDescription(), + 'Apartment' => $this->getApartment(), + 'Floor' => $this->getFloor(), + ]; + } +} \ No newline at end of file diff --git a/src/API/Classes/Attachment.php b/src/API/Classes/Attachment.php new file mode 100644 index 0000000..27c9cd2 --- /dev/null +++ b/src/API/Classes/Attachment.php @@ -0,0 +1,89 @@ +fileName; + } + + /** + * The file name without its extension. + * @param string $fileName + * @return $this + */ + public function setFileName(string $fileName) + { + $this->fileName = $fileName; + return $this; + } + + /** + * @return string + */ + public function getFileExtension() + { + return $this->fileExtension; + } + + /** + * The extension of the file. Our system accepts any extension + * @param string $fileExtension + * @return $this + */ + public function setFileExtension(string $fileExtension) + { + $this->fileExtension = $fileExtension; + return $this; + } + + /** + * @return string + */ + public function getFileContent() + { + return $this->fileContent; + } + + /** + * Contents of the file. + * @param $fileContent + * @return $this + */ + public function setFileContent(string $fileContent) + { + $this->fileContent = $fileContent; + return $this; + } + + /** + * @return array + */ + public function normalize(): array + { + return [ + 'FileName' => $this->getFileName(), + 'FileExtension' => $this->getFileExtension(), + 'FileContent' => $this->getFileContent() + ]; + } +} \ No newline at end of file diff --git a/src/API/Classes/ClientInfo.php b/src/API/Classes/ClientInfo.php new file mode 100644 index 0000000..2596c94 --- /dev/null +++ b/src/API/Classes/ClientInfo.php @@ -0,0 +1,188 @@ +useVersion2(); + } + + /** + * @return string + */ + public function getAccountCountryCode() + { + return $this->accountCountryCode; + } + + /** + * @param string $accountCountryCode + * @return $this + */ + public function setAccountCountryCode(string $accountCountryCode) + { + $this->accountCountryCode = $accountCountryCode; + return $this; + } + + /** + * @return string + */ + public function getAccountEntity() + { + return $this->accountEntity; + } + + /** + * @param string $accountEntity + * @return $this + */ + public function setAccountEntity(string $accountEntity) + { + $this->accountEntity = $accountEntity; + return $this; + } + + /** + * @return string + */ + public function getAccountNumber() + { + return $this->accountNumber; + } + + /** + * @param string $accountNumber + * @return $this + */ + public function setAccountNumber(string $accountNumber) + { + $this->accountNumber = $accountNumber; + return $this; + } + + /** + * @return string + */ + public function getAccountPin() + { + return $this->accountPin; + } + + /** + * @param string $accountPin + * @return $this + */ + public function setAccountPin(string $accountPin) + { + $this->accountPin = $accountPin; + return $this; + } + + /** + * @return string + */ + public function getUserName() + { + return $this->userName; + } + + /** + * @param string $userName + * @return $this + */ + public function setUserName(string $userName) + { + $this->userName = $userName; + return $this; + } + + /** + * @return string + */ + public function getPassword() + { + return $this->password; + } + + /** + * @param string $password + * @return $this + */ + public function setPassword(string $password) + { + $this->password = $password; + return $this; + } + + /** + * @return string + */ + public function getVersion() + { + return $this->version; + } + + /** + * @param string $version + * @return $this + */ + public function setVersion(string $version) + { + $this->version = $version; + return $this; + } + + /** + * @return ClientInfo + */ + public function useVersion1() + { + return $this->setVersion('v1.0'); + } + + /** + * @return ClientInfo + */ + public function useVersion2() + { + return $this->setVersion('v2.0'); + } + + public function normalize(): array + { + return [ + 'AccountCountryCode' => $this->getAccountCountryCode(), + 'AccountEntity' => $this->getAccountEntity(), + 'AccountNumber' => $this->getAccountNumber(), + 'AccountPin' => $this->getAccountPin(), + 'UserName' => $this->getUserName(), + 'Password' => $this->getPassword(), + 'Version' => $this->getVersion() + ]; + } +} \ No newline at end of file diff --git a/src/API/Classes/Contact.php b/src/API/Classes/Contact.php new file mode 100644 index 0000000..b05f53a --- /dev/null +++ b/src/API/Classes/Contact.php @@ -0,0 +1,278 @@ +department; + } + + /** + * User’s Work Department + * @param string $department + * @return $this + */ + public function setDepartment(string $department) + { + $this->department = $department; + return $this; + } + + /** + * @return string + */ + public function getPersonName() + { + return $this->personName; + } + + /** + * User’s Name, Sent By or in the case of the consignee, to the Attention of. + * @param string $personName + * @return $this + */ + public function setPersonName(string $personName) + { + $this->personName = $personName; + return $this; + } + + /** + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * User’s Title + * @param string $title + * @return $this + */ + public function setTitle(string $title) + { + $this->title = $title; + return $this; + } + + /** + * @return string + */ + public function getCompanyName() + { + return $this->companyName; + } + + /** + * Company or Person name. + * @param string $companyName + * @return $this + */ + public function setCompanyName(string $companyName) + { + $this->companyName = $companyName; + return $this; + } + + /** + * @return string + */ + public function getPhoneNumber1() + { + return $this->phoneNumber1; + } + + /** + * Valid Phone Number + * @param string $phoneNumber1 + * @return $this + */ + public function setPhoneNumber1(string $phoneNumber1) + { + $this->phoneNumber1 = $phoneNumber1; + return $this; + } + + /** + * @return string + */ + public function getPhoneNumber1Ext() + { + return $this->phoneNumber1Ext; + } + + /** + * Valid Extension to the phone number. + * @param string $phoneNumber1Ext + * @return $this + */ + public function setPhoneNumber1Ext(string $phoneNumber1Ext) + { + $this->phoneNumber1Ext = $phoneNumber1Ext; + return $this; + } + + /** + * @return string + */ + public function getPhoneNumber2() + { + return $this->phoneNumber2; + } + + /** + * Valid Phone Number + * @param string $phoneNumber2 + * @return $this + */ + public function setPhoneNumber2(string $phoneNumber2) + { + $this->phoneNumber2 = $phoneNumber2; + return $this; + } + + /** + * @return string + */ + public function getPhoneNumber2Ext() + { + return $this->phoneNumber2Ext; + } + + /** + * Valid Extension to the phone number. + * @param string $phoneNumber2Ext + * @return $this + */ + public function setPhoneNumber2Ext(string $phoneNumber2Ext) + { + $this->phoneNumber2Ext = $phoneNumber2Ext; + return $this; + } + + /** + * @return string + */ + public function getFaxNumber() + { + return $this->faxNumber; + } + + /** + * Fax Number + * @param string $faxNumber + * @return $this + */ + public function setFaxNumber(string $faxNumber) + { + $this->faxNumber = $faxNumber; + return $this; + } + + /** + * @return string + */ + public function getCellPhone() + { + return $this->cellPhone; + } + + /** + * Cell Phone Number + * @param string $cellPhone + * @return $this + */ + public function setCellPhone(string $cellPhone) + { + $this->cellPhone = $cellPhone; + return $this; + } + + /** + * @return string + */ + public function getEmailAddress() + { + return $this->emailAddress; + } + + /** + * Email Address + * @param string $emailAddress + * @return $this + */ + public function setEmailAddress(string $emailAddress) + { + $this->emailAddress = $emailAddress; + return $this; + } + + /** + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * @param string $type + * @return $this + */ + public function setType(string $type) + { + $this->type = $type; + return $this; + } + + public function normalize(): array + { + return [ + 'Department' => $this->getDepartment(), + 'PersonName' => $this->getPersonName(), + 'Title' => $this->getTitle(), + 'CompanyName' => $this->getCompanyName(), + 'PhoneNumber1' => $this->getPhoneNumber1(), + 'PhoneNumber1Ext' => $this->getPhoneNumber1Ext(), + 'PhoneNumber2' => $this->getPhoneNumber2(), + 'PhoneNumber2Ext' => $this->getPhoneNumber2Ext(), + 'FaxNumber' => $this->getFaxNumber(), + 'CellPhone' => $this->getCellPhone(), + 'EmailAddress' => $this->getEmailAddress(), + 'Type' => $this->getType() + ]; + } +} \ No newline at end of file diff --git a/src/API/Classes/Country.php b/src/API/Classes/Country.php new file mode 100644 index 0000000..573e9cb --- /dev/null +++ b/src/API/Classes/Country.php @@ -0,0 +1,156 @@ +code; + } + + /** + * @param string|null $code + */ + public function setCode(string $code): Country + { + $this->code = $code; + return $this; + } + + /** + * @return string|null + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param string|null $name + */ + public function setName(string $name): Country + { + $this->name = $name; + return $this; + } + + /** + * @return string|null + */ + public function getIsoCode(): ?string + { + return $this->isoCode; + } + + /** + * @param string|null $isoCode + */ + public function setIsoCode(string $isoCode): Country + { + $this->isoCode = $isoCode; + return $this; + } + + /** + * @return bool - defaukt: false + */ + public function getStateRequired(): bool + { + return $this->stateRequired; + } + + /** + * @param bool $stateRequired + */ + public function setStateRequired(bool $stateRequired): Country + { + $this->stateRequired = $stateRequired; + return $this; + } + + /** + * @return bool - defaukt: false + */ + public function getPostCodeRequired(): bool + { + return $this->postCodeRequired; + } + + /** + * @param bool $postCodeRequired + */ + public function setPostCodeRequired(bool $postCodeRequired): Country + { + $this->postCodeRequired = $postCodeRequired; + return $this; + } + + /** + * @return array|null + */ + public function getPostCodeRegex(): ?array + { + return $this->postCodeRegex; + } + + /** + * @param array $postCodeRegex + * todo + */ + public function setPostCodeRegex(array $postCodeRegex): Country + { + $this->postCodeRegex = $postCodeRegex; + return $this; + } + + /** + * @return string|null + */ + public function getInternationalCallingNumber(): ?string + { + return $this->internationalCallingNumber; + } + + /** + * @param string|null $internationalCallingNumber + */ + public function setInternationalCallingNumber(string $internationalCallingNumber): Country + { + $this->internationalCallingNumber = $internationalCallingNumber; + return $this; + } + + public function normalize(): array + { + return [ + 'Code' => $this->getCode(), + 'Name' => $this->getName(), + 'IsoCode' => $this->getIsoCode(), + 'StateRequired' => $this->getStateRequired(), + 'PostCodeRequired' => $this->getPostCodeRequired(), + 'PostCodeRegex' => $this->getPostCodeRegex(), + 'InternationalCallingNumber' => $this->getInternationalCallingNumber(), + ]; + } +} \ No newline at end of file diff --git a/src/API/Classes/DateTime.php b/src/API/Classes/DateTime.php new file mode 100644 index 0000000..9bb0359 --- /dev/null +++ b/src/API/Classes/DateTime.php @@ -0,0 +1,55 @@ +shippingDate; + } + + /** + * The date Aramex receives the shipment to be shipped out. + * @param mixed $shippingDate + */ + public function setShippingDate($shippingDate): void + { + $this->shippingDate = $shippingDate; + } + + /** + * @return mixed + */ + public function getDueDate() + { + return $this->dueDate; + } + + /** + * The date specified for shipment to be delivered to the consignee. + * @param mixed $dueDate + */ + public function setDueDate($dueDate): void + { + $this->dueDate = $dueDate; + } + + + public function normalize(): array + { + return [ + 'ShippingDate' => $this->getShippingDate(), + 'DueDate' => $this->getDueDate(), + ]; + } +} \ No newline at end of file diff --git a/src/API/Classes/Dimension.php b/src/API/Classes/Dimension.php new file mode 100644 index 0000000..5a6ebde --- /dev/null +++ b/src/API/Classes/Dimension.php @@ -0,0 +1,126 @@ +length; + } + + /** + * Measurements required in calculating the Chargeable Weight, If any of the Dimensional values are filled then the rest must be filled. + * @param float $length + * @return $this + */ + public function setLength(float $length) + { + $this->length = $length; + return $this; + } + + /** + * @return float + */ + public function getWidth() + { + return $this->width; + } + + /** + * Measurements required in calculating the Chargeable Weight, If any of the Dimensional values are filled then the rest must be filled. + * @param float $width + * @return $this + */ + public function setWidth(float $width) + { + $this->width = $width; + return $this; + } + + /** + * @return float + */ + public function getHeight() + { + return $this->height; + } + + /** + * Measurements required in calculating the Chargeable Weight, If any of the Dimensional values are filled then the rest must be filled. + * @param float $height + * @return $this + */ + public function setHeight(float $height) + { + $this->height = $height; + return $this; + } + + /** + * @return string + */ + public function getUnit() + { + return $this->unit; + } + + /** + * Measurement Unit, If any of the Dimensional values are filled then the rest must be filled. + * CM = Centimeter + * M = Meter + * @param string $unit + * @return $this + */ + public function setUnit(string $unit) + { + $this->unit = $unit; + return $this; + } + + /** + * Centimeter + * @return $this + */ + public function useCentimeterAsUnit() + { + return $this->setUnit('CM'); + } + + /** + * Meter + * @return $this + */ + public function useMeterAsUnit() + { + return $this->setUnit('M'); + } + + public function normalize(): array + { + return [ + 'Length' => $this->getLength(), + 'Width' => $this->getWidth(), + 'Height' => $this->getHeight(), + 'Unit' => $this->getUnit() + ]; + } +} \ No newline at end of file diff --git a/src/API/Classes/LabelInfo.php b/src/API/Classes/LabelInfo.php new file mode 100644 index 0000000..25b4c72 --- /dev/null +++ b/src/API/Classes/LabelInfo.php @@ -0,0 +1,65 @@ +reportId; + } + + /** + * The Template of the report to be generated. + * + * @param int $reportId + * @return $this + */ + public function setReportId(int $reportId) + { + $this->reportId = $reportId; + return $this; + } + + /** + * @return string + */ + public function getReportType(): string + { + return $this->reportType; + } + + /** + * Either by URL or a streamed file (RPT). URL by Default + * @param string $reportType : URL|RPT + * @return $this + */ + public function setReportType(string $reportType) + { + $this->reportType = $reportType; + return $this; + } + + public function normalize(): array + { + return [ + 'ReportID' => $this->getReportId(), + 'ReportType' => $this->getReportType() + ]; + } +} \ No newline at end of file diff --git a/src/API/Classes/Money.php b/src/API/Classes/Money.php new file mode 100644 index 0000000..12a28fb --- /dev/null +++ b/src/API/Classes/Money.php @@ -0,0 +1,85 @@ +currencyCode; + } + + /** + * 3-Letter Standard ISO Currency Code + * @param string $currencyCode + * @return $this + */ + public function setCurrencyCode(string $currencyCode) + { + $this->currencyCode = $currencyCode; + return $this; + } + + /** + * United States Dollar + * @return Money + */ + public function useUnitedStatesDollarAsCurrency() + { + return $this->setCurrencyCode('USD'); + } + + /** + * @return mixed + */ + public function getValue() + { + return $this->value; + } + + /** + * The Monetary value. + * @param float $value + * @return $this + */ + public function setValue(float $value) + { + $this->value = $value; + return $this; + } + + public function normalize(): array + { + return [ + 'CurrencyCode' => $this->getCurrencyCode(), + 'Value' => $this->getValue() + ]; + } + + /** + * @param object $obj + * @return Money + */ + public static function parse($obj) + { + if (!$obj) + return new self(); + + return (new self())->setCurrencyCode(object_get($obj, "CurrencyCode"))->setValue(object_get($obj, "Value")); + } +} \ No newline at end of file diff --git a/src/API/Classes/Notification.php b/src/API/Classes/Notification.php new file mode 100644 index 0000000..ea423fe --- /dev/null +++ b/src/API/Classes/Notification.php @@ -0,0 +1,83 @@ +code; + } + + /** + * To Identify the notification category. + * + * @param string $code + * @return $this + */ + public function setCode(string $code) + { + $this->code = $code; + return $this; + } + + /** + * @return string + */ + public function getMessage(): string + { + return $this->message; + } + + /** + * Deeper description of the Notification. + * + * @param string $message + * @return $this + */ + public function setMessage(string $message) + { + $this->message = $message; + return $this; + } + + /** + * @param object $notificationsData + * @return self[] + */ + public static function parseArray($notificationsData) + { + if (!$notificationsData || !object_get($notificationsData, 'Notification')) + return []; + + if (is_object($notificationsData->Notification)) { + $notificationsData = [$notificationsData->Notification]; + } else { + $notificationsData = $notificationsData->Notification; + } + + return array_map(function ($item) { + return self::parse($item); + }, $notificationsData); + } + + public static function parse($item) + { + return (new self()) + ->setCode(object_get($item, 'Code')) + ->setMessage(object_get($item, 'Message')); + } +} \ No newline at end of file diff --git a/src/API/Classes/Office.php b/src/API/Classes/Office.php new file mode 100644 index 0000000..ea97068 --- /dev/null +++ b/src/API/Classes/Office.php @@ -0,0 +1,186 @@ +entity; + } + + /** + * @param string $entity + */ + public function setEntity(string $entity): Office + { + $this->entity = $entity; + return $this; + } + + /** + * @return string + */ + public function getEntityDescription(): string + { + return $this->entityDescription; + } + + /** + * @param string $entityDescription + */ + public function setEntityDescription(string $entityDescription): Office + { + $this->entityDescription = $entityDescription; + return $this; + } + + /** + * @return string + */ + public function getOfficeType(): string + { + return $this->officeType; + } + + /** + * @param string $officeType + */ + public function setOfficeType(string $officeType): Office + { + $this->officeType = $officeType; + return $this; + } + + /** + * @return Address + */ + public function getAddress(): Address + { + return $this->address; + } + + /** + * @param Address $address + */ + public function setAddress(Address $address): Office + { + $this->address = $address; + return $this; + } + + /** + * @return string|null + */ + public function getTelephone(): ?string + { + return $this->telephone; + } + + /** + * @param string|null $telephone + */ + public function setTelephone(?string $telephone): Office + { + $this->telephone = $telephone; + return $this; + } + + /** + * @return string + */ + public function getWorkingDays(): string + { + return $this->workingDays; + } + + /** + * @param string $workingDays + */ + public function setWorkingDays(string $workingDays): Office + { + $this->workingDays = $workingDays; + return $this; + } + + /** + * @return string + */ + public function getWorkingHours(): string + { + return $this->workingHours; + } + + /** + * @param string $workingHours + */ + public function setWorkingHours(string $workingHours): Office + { + $this->workingHours = $workingHours; + return $this; + } + + /** + * @return float|null + */ + public function getLongtitude(): ?float + { + return $this->longtitude; + } + + /** + * @param mixed $longtitude + */ + public function setLongtitude(float $longtitude): Office + { + $this->longtitude = $longtitude; + return $this; + } + + /** + * @return float|null + */ + public function getLatitude(): ?float + { + return $this->latitude; + } + + /** + * @param float $latitude + */ + public function setLatitude(float $latitude): Office + { + $this->latitude = $latitude; + return $this; + } + + + public function normalize(): array + { + return [ + 'Code' => $this->getCode(), + ]; + } +} \ No newline at end of file diff --git a/src/API/Classes/Party.php b/src/API/Classes/Party.php new file mode 100644 index 0000000..eb63741 --- /dev/null +++ b/src/API/Classes/Party.php @@ -0,0 +1,138 @@ +reference1; + } + + /** + * Any details the client would like to add that will be sent back in the response. + * + * @param string $reference1 + * @return $this + */ + public function setReference1(string $reference1): Party + { + $this->reference1 = $reference1; + return $this; + } + + /** + * @return string + */ + public function getReference2(): ?string + { + return $this->reference2; + } + + /** + * Any details the client would like to add that will be sent back in the response. + * + * @param string $reference2 + * @return Party + */ + public function setReference2(string $reference2): Party + { + $this->reference2 = $reference2; + return $this; + } + + /** + * @return string + */ + public function getAccountNumber(): ?string + { + return $this->accountNumber; + } + + /** + * The Same Account number entered in the Client Info + * + * @param string $accountNumber + * @return $this + */ + public function setAccountNumber(string $accountNumber) + { + $this->accountNumber = $accountNumber; + return $this; + } + +// public function useClientAccountNumberAsAccountNumber() +// { +// return $this->setAccountNumber(''); +// } + + /** + * @return Address + */ + public function getPartyAddress(): Address + { + return $this->partyAddress; + } + + /** + * @param Address $partyAddress + * @return Party + */ + public function setPartyAddress(Address $partyAddress): Party + { + $this->partyAddress = $partyAddress; + return $this; + } + + /** + * @return Contact + */ + public function getContact(): Contact + { + return $this->contact; + } + + /** + * @param Contact $contact + * @return Party + */ + public function setContact(Contact $contact) + { + $this->contact = $contact; + return $this; + } + + /** + * @return array + */ + public function normalize(): array + { + return [ + 'Reference1' => $this->getReference1(), + 'Reference2' => $this->getReference2(), + 'AccountNumber' => $this->getAccountNumber(), + 'PartyAddress' => optional($this->getPartyAddress())->normalize(), + 'Contact' => optional($this->getContact())->normalize() + ]; + } +} \ No newline at end of file diff --git a/src/API/Classes/Pickup.php b/src/API/Classes/Pickup.php new file mode 100644 index 0000000..e0f4071 --- /dev/null +++ b/src/API/Classes/Pickup.php @@ -0,0 +1,353 @@ +pickupAddress; + } + + /** + * Pickup Address. + * + * @param Address $pickupAddress + * @return Pickup + */ + public function setPickupAddress(Address $pickupAddress) + { + $this->pickupAddress = $pickupAddress; + return $this; + } + + /** + * @return Contact + */ + public function getPickupContact(): Contact + { + return $this->pickupContact; + } + + /** + * @param Contact $pickupContact + * @return Pickup + */ + public function setPickupContact(Contact $pickupContact) + { + $this->pickupContact = $pickupContact; + return $this; + } + + /** + * @return string + */ + public function getPickupLocation(): string + { + return $this->pickupLocation; + } + + /** + * @param string $pickupLocation + * @return Pickup + */ + public function setPickupLocation(string $pickupLocation) + { + $this->pickupLocation = $pickupLocation; + return $this; + } + + /** + * @return int + */ + public function getPickupDate(): int + { + return $this->pickupDate; + } + + /** + * @param int $pickupDate + * @return Pickup + */ + public function setPickupDate(int $pickupDate): Pickup + { + $this->pickupDate = $pickupDate; + return $this; + } + + /** + * @return int + */ + public function getReadyTime(): int + { + return $this->readyTime; + } + + /** + * Ready time should always be before latest and closingtime. + * Date should not be before the current day or more than seven days in advance of the current date. + * + * @param string $readyTime + * @return Pickup + */ + public function setReadyTime(int $readyTime) + { + $this->readyTime = $readyTime; + return $this; + } + + /** + * @return int + */ + public function getLastPickupTime(): int + { + return $this->lastPickupTime; + } + + /** + * @param int $lastPickupTime + * @return Pickup + */ + public function setLastPickupTime(int $lastPickupTime): Pickup + { + $this->lastPickupTime = $lastPickupTime; + return $this; + } + + /** + * @return int + */ + public function getClosingTime(): int + { + return $this->closingTime; + } + + /** + * @param int $closingTime + * @return Pickup + */ + public function setClosingTime(int $closingTime): Pickup + { + $this->closingTime = $closingTime; + return $this; + } + + /** + * @return string + */ + public function getComments(): ?string + { + return $this->comments; + } + + /** + * @param string $comments + * @return Pickup + */ + public function setComments(string $comments) + { + $this->comments = $comments; + return $this; + } + + /** + * @return string + */ + public function getReference1(): string + { + return $this->reference1; + } + + /** + * Any general detail the customer would like to add about the shipment. + * + * @param string $reference1 + * @return Pickup + */ + public function setReference1(string $reference1) + { + $this->reference1 = $reference1; + return $this; + } + + /** + * @return string + */ + public function getReference2(): ?string + { + return $this->reference2; + } + + /** + * Any general detail the customer would like to add about the shipment. + * + * @param string $reference2 + * @return Pickup + */ + public function setReference2(string $reference2) + { + $this->reference2 = $reference2; + return $this; + } + + /** + * @return string + */ + public function getVehicle(): ?string + { + return $this->vehicle; + } + + /** + * Type of Vehicle requested to transport the shipments. + * + * @param string $vehicle + * @return Pickup + */ + public function setVehicle($vehicle): Pickup + { + $this->vehicle = $vehicle; + return $this; + } + + /** + * @return Shipment[] + */ + public function getShipments(): ?array + { + return $this->shipments; + } + + /** + * @param Shipment[] $shipments + * @return Pickup + */ + public function setShipments(array $shipments) + { + $this->shipments = $shipments; + return $this; + } + + /** + * @param Shipment $shipment + * @return Pickup + */ + public function addShipment(Shipment $shipment): Pickup + { + $this->shipments[] = $shipment; + return $this; + } + + /** + * @return PickupItem[] + */ + public function getPickItems(): array + { + return $this->pickItems; + } + + /** + * @param PickupItem[] $pickItems + * @return Pickup + */ + public function setPickItems(array $pickItems) + { + $this->pickItems = $pickItems; + return $this; + } + + /** + * @param PickupItem $pickItems + * @return Pickup + */ + public function addPickupItem(PickupItem $pickItems): Pickup + { + $this->pickItems[] = $pickItems; + return $this; + } + + /** + * @return string + */ + public function getStatus(): string + { + return $this->status; + } + + /** + * Ready or Pending + * Pending: more information about the pickup needs to be added, + * Ready: no further information is needed and the pickup request is ready to be assigned. + * + * @param string $status + * @return Pickup + */ + public function setStatus(string $status) + { + $this->status = $status; + return $this; + } + + public function normalize(): array + { + return [ + 'PickupAddress' => $this->getPickupAddress()->normalize(), + 'PickupContact' => $this->getPickupContact()->normalize(), + 'PickupLocation' => $this->getPickupLocation(), + 'PickupDate' => $this->getPickupDate(), + 'ReadyTime' => $this->getReadyTime(), + 'LastPickupTime' => $this->getLastPickupTime(), + 'ClosingTime' => $this->getClosingTime(), + 'Comments' => $this->getComments(), + 'Reference1' => $this->getReference1(), + 'Reference2' => $this->getReference2(), + 'Vehicle' => $this->getVehicle(), + 'Shipments' => $this->getShipments() ? array_map(function ($item) { + /** @var Shipment $item */ + return $item->normalize(); + }, $this->getShipments()) : [], + 'PickupItems' => $this->getPickItems() ? array_map(function ($item) { + /** @var PickupItem $item */ + return $item->normalize(); + }, $this->getPickItems()) : [], + 'Status' => $this->getStatus(), + ]; + } + +} \ No newline at end of file diff --git a/src/API/Classes/PickupItem.php b/src/API/Classes/PickupItem.php new file mode 100644 index 0000000..be64cb0 --- /dev/null +++ b/src/API/Classes/PickupItem.php @@ -0,0 +1,292 @@ +productGroup; + } + + /** + * EXP = Express + * DOM = Domestic + * + * @param string $productGroup + * @return PickupItem + */ + public function setProductGroup(string $productGroup): PickupItem + { + $this->productGroup = $productGroup; + return $this; + } + + /** + * @return string + */ + public function getProductType(): string + { + return $this->productType; + } + + /** + * Product Type + * involves the specification of certain features concerning the delivery of the product such as: + * Priority, Time Sensitivity, and whether it is a Document or Non-Document. + * Refer to Appendix A for a list of ProductTypes and their Product Groups + * + * @param string $productType + * @return PickupItem + */ + public function setProductType(string $productType): PickupItem + { + $this->productType = $productType; + return $this; + } + + /** + * @return int + */ + public function getNumberOfShipments(): int + { + return $this->numberOfShipments; + } + + /** + * Number of shipment + * + * @param int $numberOfShipments + * @return PickupItem + */ + public function setNumberOfShipments(int $numberOfShipments): PickupItem + { + $this->numberOfShipments = $numberOfShipments; + return $this; + } + + /** + * @return string + */ + public function getPackageType(): ?string + { + return $this->packageType; + } + + /** + * Type of packaging, for example. + * Cans, bottles, degradable Plastic. + * Options: P,C,3 + * + * @param string $packageType + * @return PickupItem + */ + public function setPackageType(string $packageType): PickupItem + { + $this->packageType = $packageType; + return $this; + } + + /** + * @return string + */ + public function getPayment(): string + { + return $this->payment; + } + + /** + * @param string $payment + * @return PickupItem + */ + public function setPayment(string $payment): PickupItem + { + $this->payment = $payment; + return $this; + } + + /** + * @return Weight + */ + public function getShipmentWeight(): Weight + { + return $this->shipmentWeight; + } + + /** + * Method of payment for shipment. + * Refer to Appendix B for more details + * + * @param Weight $shipmentWeight + * @return PickupItem + */ + public function setShipmentWeight(Weight $shipmentWeight): PickupItem + { + $this->shipmentWeight = $shipmentWeight; + return $this; + } + + /** + * @return Volume todo + */ + public function getShipmentVolume(): ?Volume + { + return $this->shipmentVolume; + } + + /** + * Volume of the Shipment + * Pieces > 0 + * MAX = 100 + * + * @param Volume $shipmentVolume + * @return PickupItem + */ + public function setShipmentVolume(Volume $shipmentVolume): PickupItem + { + $this->shipmentVolume = $shipmentVolume; + return $this; + } + + /** + * @return int + */ + public function getNumberOfPieces(): int + { + return $this->numberOfPieces; + } + + /** + * Number of shipment pieces + * + * @param int $numberOfPieces + * @return PickupItem + */ + public function setNumberOfPieces(int $numberOfPieces): PickupItem + { + $this->numberOfPieces = $numberOfPieces; + return $this; + } + + /** + * @return Money + */ + public function getCashAmount(): ?Money + { + return $this->cashAmount; + } + + /** + * @param Money $cashAmount + * @return PickupItem + */ + public function setCashAmount(Money $cashAmount): PickupItem + { + $this->cashAmount = $cashAmount; + return $this; + } + + /** + * @return Money + */ + public function getExtraCharges(): ?Money + { + return $this->extraCharges; + } + + /** + * @param Money $extraCharges + * @return PickupItem + */ + public function setExtraCharges(Money $extraCharges): PickupItem + { + $this->extraCharges = $extraCharges; + return $this; + } + + /** + * @return Dimension + */ + public function getShipmentDimensions(): ?Dimension + { + return $this->shipmentDimensions; + } + + /** + * Measurements required in calculating the Chargeable Weight, + * If any of the Dimensional values are filled then the rest must be filled. + * + * @param Dimension $shipmentDimensions + * @return PickupItem + */ + public function setShipmentDimensions(Dimension $shipmentDimensions): PickupItem + { + $this->shipmentDimensions = $shipmentDimensions; + return $this; + } + + /** + * @return string + */ + public function getComments(): ?string + { + return $this->comments; + } + + /** + * Any Comments on the Item being picked up. + * + * @param string $comments + * @return PickupItem + */ + public function setComments(string $comments): PickupItem + { + $this->comments = $comments; + return $this; + } + + /** + * @return array + */ + public function normalize(): array + { + return [ + 'ProductGroup' => $this->getProductGroup(), + 'ProductType' => $this->getProductType(), + 'NumberOfShipments' => $this->getNumberOfShipments(), + 'PackageType' => $this->getPackageType(), + 'Payment' => $this->getPayment(), + 'ShipmentWeight' => optional($this->getShipmentWeight())->normalize(), + 'ShipmentVolume' => optional($this->getShipmentVolume())->normalize(), + 'NumberOfPieces' => $this->getNumberOfPieces(), + 'CashAmount' => optional($this->getCashAmount())->normalize(), + 'ExtraCharges' => optional($this->getExtraCharges())->normalize(), + 'ShipmentDimensions' => optional($this->getShipmentDimensions())->normalize(), + 'Comments' => $this->getComments(), + ]; + } +} \ No newline at end of file diff --git a/src/API/Classes/ProcessedPickup.php b/src/API/Classes/ProcessedPickup.php new file mode 100644 index 0000000..0be86cc --- /dev/null +++ b/src/API/Classes/ProcessedPickup.php @@ -0,0 +1,142 @@ +id; + } + + /** + * A reference number that has been allocated to the submitted pickup. + * + * @param string $id + * @return ProcessedPickup + */ + public function setId(string $id): ProcessedPickup + { + $this->id = $id; + return $this; + } + + /** + * @return string + */ + public function getGUID(): string + { + return $this->guid; + } + + /** + * A reference number that has been allocated to the submitted pickup. + * + * @param string $guid + * @return ProcessedPickup + */ + public function setGUID(string $guid): ProcessedPickup + { + $this->guid = $guid; + return $this; + } + + /** + * A unique identifier that gets assigned to the submitted pickup request after being saved. + * This identifier can be used in the cancellation request at a later stage. + * + * @param string $guid + * @return ProcessedPickup + */ + public function setReference3(string $guid): ProcessedPickup + { + $this->guid = $guid; + return $this; + } + + /** + * @return string + */ + public function getReference1(): string + { + return $this->reference1; + } + + /** + * @param string $reference1 + * @return ProcessedPickup + */ + public function setReference1(string $reference1): ProcessedPickup + { + $this->reference1 = $reference1; + return $this; + } + + /** + * @return string + */ + public function getReference2(): string + { + return $this->reference2; + } + + /** + * @param string|null $reference2 + * @return ProcessedPickup + */ + public function setReference2(?string $reference2): ProcessedPickup + { + $this->reference2 = $reference2; + return $this; + } + + /** + * @return ProcessedShipment[] + */ + public function getProcessedShipments(): array + { + return $this->processedShipments; + } + + /** + * @param ProcessedShipment[] $processedShipments + * @return ProcessedPickup + */ + public function setProcessedShipments(array $processedShipments): ProcessedPickup + { + $this->processedShipments = $processedShipments; + return $this; + } + + public function normalize(): array + { + return [ + 'ID' => $this->getId(), + 'GUID' => $this->getGUID(), + 'Reference1' => $this->getReference1(), + 'Reference2' => $this->getReference2(), + 'ProcessedShipments' => $this->getProcessedShipments() ? array_map(function ($item) { + /** @var ProcessedPickup $item */ + return $item->normalize(); + }, $this->getProcessedShipments()) : [], + ]; + } +} \ No newline at end of file diff --git a/src/API/Classes/ProcessedShipment.php b/src/API/Classes/ProcessedShipment.php new file mode 100644 index 0000000..5e07ec6 --- /dev/null +++ b/src/API/Classes/ProcessedShipment.php @@ -0,0 +1,186 @@ +id; + } + + /** + * The AWB ID generated + * + * @param string $id + * @return ProcessedShipment + */ + public function setId(string $id): ProcessedShipment + { + $this->id = $id; + return $this; + } + + /** + * @return string + */ + public function getReference1(): string + { + return $this->reference1; + } + + /** + * The reference filled in the Shipment element + * + * @param string $reference1 + * @return ProcessedShipment + */ + public function setReference1(string $reference1): ProcessedShipment + { + $this->reference1 = $reference1; + } + + /** + * @return string + */ + public function getReference2(): string + { + return $this->reference2; + } + + /** + * @param string $reference2 + * @return ProcessedShipment + */ + public function setReference2(string $reference2): ProcessedShipment + { + $this->reference2 = $reference2; + } + + /** + * @return string + */ + public function getReference3(): string + { + return $this->reference3; + } + + /** + * @param string $reference3 + * @return ProcessedShipment + */ + public function setReference3(string $reference3): ProcessedShipment + { + $this->reference3 = $reference3; + } + + /** + * @return string + */ + public function getForeignHAWB(): string + { + return $this->foreignHAWB; + } + + /** + * Filled in the Shipment Element must be unique for every shipment in the system. + * + * @param string $foreignHAWB + * @return ProcessedShipment + */ + public function setForeignHAWB($foreignHAWB): ProcessedShipment + { + $this->foreignHAWB = $foreignHAWB; + return $this; + } + + /** + * @return bool + */ + public function getHasErrors(): bool + { + return $this->hasErrors; + } + + /** + * @param bool $hasErrors + * @return ProcessedShipment + */ + public function setHasErrors(bool $hasErrors): ProcessedShipment + { + $this->hasErrors = $hasErrors; + return $this; + } + + /** + * @return Notification[] + */ + public function getNotifications(): array + { + return $this->notifications; + } + + /** + * @param Notification[] $notifications + * @return ProcessedShipment + */ + public function setNotifications(array $notifications): ProcessedShipment + { + $this->notifications = $notifications; + return $this; + } + + /** + * @return ShipmentLabel + */ + public function getShipmentLabel(): ShipmentLabel + { + return $this->shipmentLabel; + } + + /** + * @param ShipmentLabel $shipmentLabel + * @return ProcessedShipment + */ + public function setShipmentLabel(ShipmentLabel $shipmentLabel): ProcessedShipment + { + $this->shipmentLabel = $shipmentLabel; + return $this; + } + + public function normalize(): array + { + return [ + 'ID' => $this->getId(), + 'Reference1' => $this->getReference1(), + 'Reference2' => $this->getReference2(), + 'Reference3' => $this->getReference3(), + 'ForeignHAWB' => $this->getForeignHAWB(), + 'HasErrors' => $this->getHasErrors(), + 'Notifications' => $this->getNotifications(), + 'ShipmentLabel' => $this->getShipmentLabel(), + ]; + } +} \ No newline at end of file diff --git a/src/API/Classes/ScheduledDelivery.php b/src/API/Classes/ScheduledDelivery.php new file mode 100644 index 0000000..e4abbb8 --- /dev/null +++ b/src/API/Classes/ScheduledDelivery.php @@ -0,0 +1,14 @@ +reference1; + } + + /** + * Any general detail the customer would like to add about the shipment + * + * @param string $reference1 + * @return $this + */ + public function setReference1(string $reference1) + { + $this->reference1 = $reference1; + return $this; + } + + /** + * @return string|null + */ + public function getReference2(): ?string + { + return $this->reference2; + } + + /** + * Any general detail the customer would like to add about the shipment + * + * @param string $reference2 + * @return $this + */ + public function setReference2(string $reference2) + { + $this->reference2 = $reference2; + return $this; + } + + /** + * @return string|null + */ + public function getReference3(): ?string + { + return $this->reference3; + } + + /** + * Any general detail the customer would like to add about the shipment + * + * @param string $reference3 + * @return $this + */ + public function setReference3(string $reference3) + { + $this->reference3 = $reference3; + return $this; + } + + /** + * @return Party + */ + public function getShipper(): Party + { + return $this->shipper; + } + + /** + * @param Party $shipper + * @return $this + */ + public function setShipper(Party $shipper) + { + $this->shipper = $shipper; + return $this; + } + + /** + * @return Party + */ + public function getConsignee(): Party + { + return $this->consignee; + } + + /** + * @param Party $consignee + * @return $this + */ + public function setConsignee(Party $consignee) + { + $this->consignee = $consignee; + return $this; + } + + /** + * @return Party + */ + public function getThirdParty(): ?Party + { + return $this->thirdParty; + } + + /** + * @param Party $thirdParty + * @return $this + */ + public function setThirdParty(Party $thirdParty) + { + $this->thirdParty = $thirdParty; + return $this; + } + + /** + * @return int + */ + public function getShippingDateTime() + { + return $this->shippingDateTime; + } + + /** + * The date aramex receives the shipment to be shipped out. + * + * @param int $shippingDateTime + * @return $this + */ + public function setShippingDateTime(int $shippingDateTime) + { + $this->shippingDateTime = $shippingDateTime; + return $this; + } + + /** + * @return int + */ + public function getDueDate() + { + return $this->dueDate; + } + + /** + * The date specified for shipment to be delivered to the consignee. + * + * @param int $dueDate + * @return $this + */ + public function setDueDate(int $dueDate) + { + $this->dueDate = $dueDate; + return $this; + } + + /** + * @return string|null + */ + public function getComments(): ?string + { + return $this->comments; + } + + /** + * Any comments on the shipment. + * + * @param string $comments + * @return $this + */ + public function setComments(string $comments) + { + $this->comments = $comments; + return $this; + } + + /** + * @return string + */ + public function getPickupLocation(): string + { + return $this->pickupLocation; + } + + /** + * The location from where the shipment should be picked up, such as the reception desk. + * + * @param string $pickupLocation + * @return $this + */ + public function setPickupLocation(string $pickupLocation) + { + $this->pickupLocation = $pickupLocation; + return $this; + } + + /** + * @return string|null + */ + public function getOperationsInstructions(): ?string + { + return $this->operationsInstructions; + } + + /** + * Instructions on how to handle the shipment. + * + * @param string $operationsInstructions + * @return $this + */ + public function setOperationsInstructions(string $operationsInstructions) + { + $this->operationsInstructions = $operationsInstructions; + return $this; + } + + /** + * @return string|null + */ + public function getAccountingInstructions(): ?string + { + return $this->accountingInstructions; + } + + /** + * Instructions on how to handle payment specifics. + * + * @param string $accountingInstructions + * @return $this + */ + public function setAccountingInstructions(string $accountingInstructions) + { + $this->accountingInstructions = $accountingInstructions; + return $this; + } + + /** + * @return ShipmentDetails + */ + public function getDetails(): ShipmentDetails + { + return $this->details; + } + + /** + * @param ShipmentDetails $details + * @return $this + */ + public function setDetails(ShipmentDetails $details) + { + $this->details = $details; + return $this; + } + + /** + * @return Attachment[] + */ + public function getAttachments(): ?array + { + return $this->attachments; + } + + /** + * The total size of a single file must not exceed 2 MB. + * @param array $attachments + * @return $this + */ + public function setAttachments(array $attachments) + { + $this->attachments = $attachments; + return $this; + } + + /** + * @param Attachment $attachment + * @return $this + */ + public function addAttachment(Attachment $attachment) + { + $this->attachments[] = $attachment; + return $this; + } + + /** + * @return string|null + */ + public function getForeignHAWB(): ?string + { + return $this->foreignHAWB; + } + + /** + * Client’s shipment number if present. If filled this field must be unique for each shipment. + * + * @param string $foreignHAWB + * @return $this + */ + public function setForeignHAWB(string $foreignHAWB) + { + $this->foreignHAWB = $foreignHAWB; + return $this; + } + + /** + * 0 or 1 + * 0 by Default + * @return int + */ + public function getTransportType(): int + { + return $this->transportType; + } + + /** + * @param int $transportType + * @return $this + */ + public function setTransportType(int $transportType) + { + $this->transportType = $transportType; + return $this; + } + + /** + * A valid HAWB number + * @return string|null + */ + public function getNumber(): ?string + { + return $this->number; + } + + /** + * If shipment numbers are required to be entered manually + * then aramex operations will provide a stock range from which to fill this field with. + * Otherwise if empty a number will be assigned to the created shipment automatically and returned in the response. + * + * @param string $number + * @return $this + */ + public function setNumber(string $number) + { + $this->number = $number; + return $this; + } + + /** + * To add Shipments to existing pickups. + * + * @return string|null + */ + public function getPickupGUID(): ?string + { + return $this->pickupGUID; + } + + /** + * A valid GUID value, provided by the Pickup Creation Response + * + * @param string $pickupGUID + * @return $this + */ + public function setPickupGUID(string $pickupGUID) + { + $this->pickupGUID = $pickupGUID; + return $this; + } + + + public function normalize(): array + { + return [ + 'Reference1' => $this->getReference1(), + 'Reference2' => $this->getReference2(), + 'Reference3' => $this->getReference3(), + 'Shipper' => optional($this->getShipper())->normalize(), + 'Consignee' => optional($this->getConsignee())->normalize(), + 'ThirdParty' => optional($this->getThirdParty())->normalize(), + 'ShippingDateTime' => $this->getShippingDateTime(), + 'DueDate' => $this->getDueDate(), + 'Comments' => $this->getComments(), + 'PickupLocation' => $this->getPickupLocation(), + 'OperationsInstructions' => $this->getOperationsInstructions(), + 'AccountingInstructions' => $this->getAccountingInstructions(), + 'Details' => optional($this->getDetails())->normalize(), + 'Attachments' => $this->getAttachments() ? array_map(function ($item) { + return $item->normalize(); + }, $this->getAttachments()) : [], + 'ForeignHAWB' => $this->getForeignHAWB(), + 'TransportType' => $this->getTransportType(), + 'Number' => $this->getNumber(), + 'PickupGUID' => $this->getPickupGUID() + ]; + } +} \ No newline at end of file diff --git a/src/API/Classes/ShipmentDetails.php b/src/API/Classes/ShipmentDetails.php new file mode 100644 index 0000000..8e02318 --- /dev/null +++ b/src/API/Classes/ShipmentDetails.php @@ -0,0 +1,502 @@ +dimensions; + } + + /** + * Measurements required in calculating the Chargeable Weight, If any of the dimensional values are filled then the rest must be filled. + * @param Dimension $dimensions + * @return $this + */ + public function setDimensions(Dimension $dimensions) + { + $this->dimensions = $dimensions; + return $this; + } + + /** + * @return Weight + */ + public function getActualWeight() + { + return $this->actualWeight; + } + + /** + * Total actual shipment weight. If the Dimensions are filled, charging weight is compared to actual and the highest value is filled here. + * @param Weight $actualWeight + * @return $this + */ + public function setActualWeight(Weight $actualWeight) + { + $this->actualWeight = $actualWeight; + return $this; + } + + /** + * @return Weight + */ + public function getChargeableWeight() + { + return $this->chargeableWeight; + } + + /** + * @param Weight $chargeableWeight + * @return $this + */ + public function setChargeableWeight(Weight $chargeableWeight) + { + $this->chargeableWeight = $chargeableWeight; + return $this; + } + + /** + * @return string + */ + public function getDescriptionOfGoods() + { + return $this->descriptionOfGoods; + } + + /** + * The Nature of Shipment Contents. Example: Clothes, Electronic + * @param string $descriptionOfGoods + * @return $this + */ + public function setDescriptionOfGoods(string $descriptionOfGoods) + { + $this->descriptionOfGoods = $descriptionOfGoods; + return $this; + } + + /** + * @return string + */ + public function getGoodsOriginCountry() + { + return $this->goodsOriginCountry; + } + + /** + * The Origin of which the product in the shipment came from + * @param string $goodsOriginCountry + * @return $this + */ + public function setGoodsOriginCountry(string $goodsOriginCountry) + { + $this->goodsOriginCountry = $goodsOriginCountry; + return $this; + } + + /** + * @return int + */ + public function getNumberOfPieces() + { + return $this->numberOfPieces; + } + + /** + * Number of shipment pieces + * @param int $numberOfPieces + * @return $this + */ + public function setNumberOfPieces(int $numberOfPieces) + { + $this->numberOfPieces = $numberOfPieces; + return $this; + } + + /** + * @return string + */ + public function getProductGroup() + { + return $this->productGroup; + } + + /** + * EXP = Express DOM = Domestic + * @param string $productGroup + * @return $this + */ + public function setProductGroup(string $productGroup) + { + $this->productGroup = $productGroup; + return $this; + } + + /** + * @return $this + */ + public function useExpressAsProductGroup() + { + return $this->setProductGroup('EXP'); + } + + /** + * @return $this + */ + public function useDomesticAsProductGroup() + { + return $this->setProductGroup('DOM'); + } + + /** + * @return string + */ + public function getProductType() + { + return $this->productType; + } + + /** + * Priority Document Express. + * Urgent, time sensitive consignments containing printed matter or document material. + * @return $this + */ + public function usePriorityDocumentExpressAsProductType() + { + return $this->setProductType('PDX'); + } + + /** + * Priority Parcel Express. + * Urgent, time sensitive consignments containing non-printed matter or non-document material. + * @return $this + */ + public function usePriorityParcelExpressAsProductType() + { + return $this->setProductType('PPX'); + } + + /** + * Priority Letter Express. + * Urgent, time sensitive consignments containing printed matter of weight less than 0.5 kg. + * @return $this + */ + public function usePriorityLetterExpressAsProductType() + { + return $this->setProductType('PLX'); + } + + /** + * Deferred Document Express. + * 2nd Day Delivery consignments containing printed matter or document material. + * @return $this + */ + public function useDeferredDocumentExpressAsProductType() + { + return $this->setProductType('DDX'); + } + + /** + * Deferred Parcel Express. + * 2nd Day Delivery consignments containing non-printed matter or non-document material. + * @return $this + */ + public function setDeferredParcelExpressProductType() + { + return $this->setProductType('DPX'); + } + + /** + * Ground Document Express. + * Ground delivery consignments containing printed matter or document material. + * @return $this + */ + public function setGroundDocumentExpressProductType() + { + return $this->setProductType('GDX'); + } + + /** + * Ground Parcel Express. + * Ground Delivery consignments containing non-printed matter or non-document material. + * @return $this + */ + public function setGroundParcelExpressProductType() + { + return $this->setProductType('GPX'); + } + + + /** + * Product Type involves the specification of certain features concerning the delivery of the product + * @param string $productType + * @return $this + */ + public function setProductType(string $productType) + { + $this->productType = $productType; + return $this; + } + + /** + * @return Money + */ + public function getCustomsValueAmount() + { + return $this->customsValueAmount; + } + + /** + * @param Money $customsValueAmount + * @return $this + */ + public function setCustomsValueAmount(Money $customsValueAmount) + { + $this->customsValueAmount = $customsValueAmount; + return $this; + } + + /** + * @return Money + */ + public function getCashOnDeliveryAmount() + { + return $this->cashOnDeliveryAmount; + } + + /** + * Amount of Cash that is paid by the receiver of the package. Conditional - Based on the Services "COD" being filled. + * @param Money $cashOnDeliveryAmount + * @return $this + */ + public function setCashOnDeliveryAmount(Money $cashOnDeliveryAmount) + { + $this->cashOnDeliveryAmount = $cashOnDeliveryAmount; + return $this; + } + + /** + * @return Money + */ + public function getInsuranceAmount() + { + return $this->insuranceAmount; + } + + /** + * Insurance Amount charged on shipment. + * @param Money $insuranceAmount + * @return $this + */ + public function setInsuranceAmount(Money $insuranceAmount) + { + $this->insuranceAmount = $insuranceAmount; + return $this; + } + + /** + * @return Money + */ + public function getCashAdditionalAmount() + { + return $this->cashAdditionalAmount; + } + + /** + * Additional Cash that can be required for miscellaneous purposes. + * @param Money $cashAdditionalAmount + * @return $this + */ + public function setCashAdditionalAmount(Money $cashAdditionalAmount) + { + $this->cashAdditionalAmount = $cashAdditionalAmount; + return $this; + } + + /** + * @return string + */ + public function getServices() + { + return $this->services; + } + + /** + * Additional Services used in shipping the package, Separate by comma when selecting multiple services. + * @param string $services + * @return $this + */ + public function setServices(string $services) + { + $this->services = $services; + return $this; + } + + /** + * Cash on Delivery. + * Receiver pays the cost of the goods + * @return $this + */ + public function useCashOnDeliveryService() + { + return $this->setServices('COD'); + } + + /** + * First Delivery. + * Committed delivery time at destination country. + * @return $this + */ + public function useFirstAsService() + { + return $this->setServices('FIRST'); + } + + public function useFreeDomicileAsService() + { + return $this->setServices('FRDOM'); + } + + public function useHoldForPickupAsService() + { + return $this->setServices('HFPU'); + } + + public function useNoonDeliveryAsService() + { + return $this->setServices('NOON'); + } + + public function useSignatureRequiredAsService() + { + return $this->setServices('SIG'); + } + + /** + * @return ShipmentItem[] + */ + public function getItems() + { + return $this->items; + } + + /** + * Details of the Items within a shipment. Several items can be added for a single shipment. + * @param $items + * @return $this + */ + public function setItems($items) + { + $this->items = $items; + return $this; + } + + /** + * @param ShipmentItem $item + * @return $this + */ + public function addItem(ShipmentItem $item) + { + $this->items[] = $item; + return $this; + } + + /** + * @return string + */ + public function getPaymentType() + { + return $this->paymentType; + } + + /** + * Method of payment for shipment. + * @param string $paymentType + * @return $this + */ + public function setPaymentType(string $paymentType) + { + $this->paymentType = $paymentType; + return $this; + } + + /** + * Prepaid. + * Transportation Charges payable by shipper. + * @return $this + */ + public function usePrepaidAsPaymentType() + { + return $this->setPaymentType('P'); + } + + /** + * Collect. + * Transportation Charges payable by consignee. + * @return $this + */ + public function useCollectAsPaymentType() + { + return $this->setPaymentType('C'); + } + + /** + * Third Party. + * Transportation Charges payable by third party. Note: in case of 3rd Party all third party details must be filled including a valid Aramex Account Number for Billing Party. + * @return $this + */ + public function useThirdPartyAsPaymentType() + { + return $this->setPaymentType('T'); + } + + public function normalize(): array + { + return [ + 'Dimensions' => optional($this->getDimensions())->normalize(), + 'ActualWeight' => optional($this->getActualWeight())->normalize(), + 'ChargeableWeight' => optional($this->getChargeableWeight())->normalize(), + 'DescriptionOfGoods' => $this->getDescriptionOfGoods(), + 'GoodsOriginCountry' => $this->getGoodsOriginCountry(), + 'NumberOfPieces' => $this->getNumberOfPieces(), + 'ProductGroup' => $this->getProductGroup(), + 'ProductType' => $this->getProductType(), + 'PaymentType' => $this->getPaymentType(), + 'CustomsValueAmount' => optional($this->getCustomsValueAmount())->normalize(), + 'CashOnDeliveryAmount' => optional($this->getCashOnDeliveryAmount())->normalize(), + 'InsuranceAmount' => optional($this->getInsuranceAmount())->normalize(), + 'CashAdditionalAmount' => optional($this->getCashAdditionalAmount())->normalize(), + 'Services' => $this->getServices(), + 'Items' => $this->getItems() ? array_map(function ($item) { + return $item->normalize(); + }, $this->getItems()) : [] + ]; + } +} \ No newline at end of file diff --git a/src/API/Classes/ShipmentItem.php b/src/API/Classes/ShipmentItem.php new file mode 100644 index 0000000..ba9bc02 --- /dev/null +++ b/src/API/Classes/ShipmentItem.php @@ -0,0 +1,130 @@ +packageType; + } + + /** + * Type of packaging, for example. Cans, bottles, degradable Plastic. Conditional: If any of the Item element values are filled then the rest must be filled. + * @param string $packageType + * @return $this + */ + public function setPackageType(string $packageType) + { + $this->packageType = $packageType; + return $this; + } + + /** + * @return int + */ + public function getQuantity(): int + { + return $this->quantity; + } + + /** + * Number of items + * @param int $quantity + * @return $this + */ + public function setQuantity(int $quantity) + { + $this->quantity = $quantity; + return $this; + } + + /** + * @return Weight + */ + public function getWeight(): Weight + { + return $this->weight; + } + + /** + * Total Weight of the Items + * @param Weight $weight + * @return $this + */ + public function setWeight(Weight $weight) + { + $this->weight = $weight; + return $this; + } + + /** + * @return string + */ + public function getComments(): string + { + return $this->comments; + } + + /** + * Additional Comments or Information about the items + * @param string $comments + * @return $this + */ + public function setComments(string $comments) + { + $this->comments = $comments; + return $this; + } + + /** + * @return string + */ + public function getReference(): string + { + return $this->reference; + } + + /** + * @param string $reference + * @return $this + */ + public function setReference(string $reference) + { + $this->reference = $reference; + return $this; + } + + /** + * @return array + */ + public function normalize(): array + { + return [ + 'PackageType' => $this->getPackageType(), + 'Quantity' => $this->getQuantity(), + 'Weight' => optional($this->getWeight())->normalize(), + 'Comments' => $this->getComments(), + 'Reference' => $this->getReference() + ]; + } +} \ No newline at end of file diff --git a/src/API/Classes/ShipmentLabel.php b/src/API/Classes/ShipmentLabel.php new file mode 100644 index 0000000..289a5df --- /dev/null +++ b/src/API/Classes/ShipmentLabel.php @@ -0,0 +1,61 @@ +labelUrl; + } + + /** + * @param string $labelUrl + * @return ShipmentLabel + */ + public function setLabelUrl(string $labelUrl): ShipmentLabel + { + $this->labelUrl = $labelUrl; + return $this; + } + + /** + * @return string + */ + public function getLabelFileContents(): string + { + return $this->labelFileContents; + } + + /** + * @param string $labelFileContents + * @return ShipmentLabel + */ + public function setLabelFileContents(string $labelFileContents): ShipmentLabel + { + $this->labelFileContents = $labelFileContents; + return $this; + } + + public function normalize(): array + { + return [ + 'LabelUrl' => $this->getLabelUrl(), + 'LabelFileContents' => $this->getLabelFileContents(), + ]; + } + +} \ No newline at end of file diff --git a/src/API/Classes/State.php b/src/API/Classes/State.php new file mode 100644 index 0000000..24a6a20 --- /dev/null +++ b/src/API/Classes/State.php @@ -0,0 +1,60 @@ +code; + } + + /** + * @param string|null $code + */ + public function setCode(string $code): State + { + $this->code = $code; + return $this; + } + + /** + * @return string|null + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param string|null $name + */ + public function setName(string $name): State + { + $this->name = $name; + return $this; + } + + public function normalize(): array + { + return [ + 'Code' => $this->getCode(), + 'Name' => $this->getName(), + ]; + } +} \ No newline at end of file diff --git a/src/API/Classes/Track.php b/src/API/Classes/Track.php new file mode 100644 index 0000000..b4380d3 --- /dev/null +++ b/src/API/Classes/Track.php @@ -0,0 +1,219 @@ +id; + } + + /** + * @param string $id + * @return $this + */ + public function setId(string $id) + { + $this->id = $id; + return $this; + } + + /** + * @return string + */ + public function getUpdateCode() + { + return $this->updateCode; + } + + /** + * @param string $updateCode + * @return $this + */ + public function setUpdateCode(string $updateCode) + { + $this->updateCode = $updateCode; + return $this; + } + + /** + * @return string + */ + public function getUpdateDescription() + { + return $this->updateDescription; + } + + /** + * @param string $updateDescription + * @return $this + */ + public function setUpdateDescription(string $updateDescription) + { + $this->updateDescription = $updateDescription; + return $this; + } + + /** + * @return string + */ + public function getUpdateDateTime() + { + return $this->updateDateTime; + } + + /** + * @param string $updateDateTime + * @return $this + */ + public function setUpdateDateTime(string $updateDateTime) + { + $this->updateDateTime = $updateDateTime; + return $this; + } + + /** + * @return string + */ + public function getUpdateLocation() + { + return $this->updateLocation; + } + + /** + * @param string $updateLocation + * @return $this + */ + public function setUpdateLocation(string $updateLocation) + { + $this->updateLocation = $updateLocation; + return $this; + } + + /** + * @return string + */ + public function getComments() + { + return $this->comments; + } + + /** + * @param string $comments + * @return $this + */ + public function setComments(string $comments) + { + $this->comments = $comments; + return $this; + } + + /** + * @return string + */ + public function getProblemCode() + { + return $this->problemCode; + } + + /** + * @param string $problemCode + * @return $this + */ + public function setProblemCode(string $problemCode) + { + $this->problemCode = $problemCode; + return $this; + } + + /** + * @return string + */ + public function getGrossWeight() + { + return $this->grossWeight; + } + + /** + * @param string $grossWeight + * @return $this + */ + public function setGrossWeight(string $grossWeight) + { + $this->grossWeight = $grossWeight; + return $this; + } + + /** + * @return string + */ + public function getChargeableWeight() + { + return $this->chargeableWeight; + } + + /** + * @param string $chargeableWeight + * @return $this + */ + public function setChargeableWeight(string $chargeableWeight) + { + $this->chargeableWeight = $chargeableWeight; + return $this; + } + + /** + * @return string + */ + public function getWeightUnit() + { + return $this->weightUnit; + } + + /** + * @param string $weightUnit + * @return $this + */ + public function setWeightUnit(string $weightUnit) + { + $this->weightUnit = $weightUnit; + return $this; + } + + /** + * @param object $obj + * @return Track + */ + public static function parse($obj) + { + $obj = $obj->Value->TrackingResult; + + return (new self())->setId($obj->WaybillNumber) + ->setUpdateCode($obj->UpdateCode) + ->setUpdateDescription($obj->UpdateDescription) + ->setUpdateDateTime($obj->UpdateDateTime) + ->setUpdateLocation($obj->UpdateLocation) + ->setComments($obj->Comments) + ->setProblemCode($obj->ProblemCode) + ->setGrossWeight($obj->GrossWeight) + ->setChargeableWeight($obj->ChargeableWeight) + ->setWeightUnit($obj->WeightUnit); + } +} \ No newline at end of file diff --git a/src/API/Classes/TrackingResult.php b/src/API/Classes/TrackingResult.php new file mode 100644 index 0000000..f0362b6 --- /dev/null +++ b/src/API/Classes/TrackingResult.php @@ -0,0 +1,244 @@ +waybillNumber; + } + + /** + * @param string $id + * @return TrackingResult + */ + public function setWaybillNumber(string $waybillNumber): TrackingResult + { + $this->waybillNumber = $waybillNumber; + return $this; + } + + /** + * @return string + */ + public function getUpdateCode(): string + { + return $this->updateCode; + } + + /** + * @param string $updateCode + * @return $this + */ + public function setUpdateCode(string $updateCode): TrackingResult + { + $this->updateCode = $updateCode; + return $this; + } + + /** + * @return string + */ + public function getUpdateDescription(): string + { + return $this->updateDescription; + } + + /** + * @param string $updateDescription + * @return $this + */ + public function setUpdateDescription(string $updateDescription): TrackingResult + { + $this->updateDescription = $updateDescription; + return $this; + } + + /** + * @return string + */ + public function getUpdateDateTime(): string + { + return $this->updateDateTime; + } + + /** + * @param string $updateDateTime + * @return $this + */ + public function setUpdateDateTime(string $updateDateTime): TrackingResult + { + $this->updateDateTime = $updateDateTime; + return $this; + } + + /** + * @return string + */ + public function getUpdateLocation(): string + { + return $this->updateLocation; + } + + /** + * @param string $updateLocation + * @return $this + */ + public function setUpdateLocation(string $updateLocation): TrackingResult + { + $this->updateLocation = $updateLocation; + return $this; + } + + /** + * @return string + */ + public function getComments(): ?string + { + return $this->comments; + } + + /** + * @param string $comments + * @return $this + */ + public function setComments(string $comments): TrackingResult + { + $this->comments = $comments; + return $this; + } + + /** + * @return string + */ + public function getProblemCode(): ?string + { + return $this->problemCode; + } + + /** + * @param string $problemCode + * @return $this + */ + public function setProblemCode(string $problemCode): TrackingResult + { + $this->problemCode = $problemCode; + return $this; + } + + /** + * @return string + */ + public function getGrossWeight(): ?string + { + return $this->grossWeight; + } + + /** + * @param string $grossWeight + * @return $this + */ + public function setGrossWeight(string $grossWeight): TrackingResult + { + $this->grossWeight = $grossWeight; + return $this; + } + + /** + * @return string + */ + public function getChargeableWeight(): ?string + { + return $this->chargeableWeight; + } + + /** + * @param string $chargeableWeight + * @return $this + */ + public function setChargeableWeight(string $chargeableWeight): TrackingResult + { + $this->chargeableWeight = $chargeableWeight; + return $this; + } + + /** + * @return string + */ + public function getWeightUnit(): ?string + { + return $this->weightUnit; + } + + /** + * @param string $weightUnit + * @return $this + */ + public function setWeightUnit(string $weightUnit): TrackingResult + { + $this->weightUnit = $weightUnit; + return $this; + } + + /** + * @param object $obj + * @return Track + */ + public static function parse($obj) + { + $obj = $obj->Value->TrackingResult; + + + return (new self()) + ->setWaybillNumber($obj->WaybillNumber) + ->setUpdateCode($obj->UpdateCode) + ->setUpdateDescription($obj->UpdateDescription) + ->setUpdateDateTime($obj->UpdateDateTime) + ->setUpdateLocation($obj->UpdateLocation) + ->setComments($obj->Comments) + ->setProblemCode($obj->ProblemCode) + ->setGrossWeight($obj->GrossWeight) + ->setChargeableWeight($obj->ChargeableWeight) + ->setWeightUnit($obj->WeightUnit); + } + + public function normalize(): array + { + return [ + 'WaybillNumber' => $this->getWaybillNumber(), + 'UpdateCode' => $this->getUpdateCode(), + 'UpdateDescription' => $this->getUpdateDescription(), + 'UpdateDateTime' => $this->getUpdateDateTime(), + 'UpdateLocation' => $this->getUpdateLocation(), + 'Comments' => $this->getComments(), + 'ProblemCode' => $this->getProblemCode(), + 'GrossWeight' => $this->getGrossWeight(), + 'ChargeableWeight' => $this->getChargeableWeight(), + 'WeightUnit' => $this->getWeightUnit(), + ]; + } + +} \ No newline at end of file diff --git a/src/API/Classes/Transaction.php b/src/API/Classes/Transaction.php new file mode 100644 index 0000000..149d310 --- /dev/null +++ b/src/API/Classes/Transaction.php @@ -0,0 +1,149 @@ +reference1; + } + + /** + * Any details the user would like to add that will be sent back in the response. + * + * @param string $reference1 + * @return $this + */ + public function setReference1(string $reference1) + { + $this->reference1 = $reference1; + return $this; + } + + /** + * @return string + */ + public function getReference2(): string + { + return $this->reference1; + } + + /** + * Any details the user would like to add that will be sent back in the response. + * + * @param string $reference2 + * @return $this + */ + public function setReference2(string $reference2) + { + $this->reference2 = $reference2; + return $this; + } + + /** + * @return string + */ + public function getReference3(): string + { + return $this->reference3; + } + + /** + * Any details the user would like to add that will be sent back in the response. + * + * @param string $reference3 + * @return $this + */ + public function setReference3(string $reference3) + { + $this->reference3 = $reference3; + return $this; + } + + /** + * @return string + */ + public function getReference4(): string + { + return $this->reference4; + } + + /** + * Any details the user would like to add that will be sent back in the response. + * + * @param string $reference4 + * @return $this + */ + public function setReference4(string $reference4) + { + $this->reference4 = $reference4; + return $this; + } + + /** + * @return string + */ + public function getReference5(): string + { + return $this->reference5; + } + + /** + * Any details the user would like to add that will be sent back in the response. + * + * @param string $reference5 + * @return $this + */ + public function setReference5(string $reference5) + { + $this->reference5 = $reference5; + return $this; + } + + public function normalize(): array + { + return [ + 'Reference1' => $this->getReference1(), + 'Reference2' => $this->getReference2(), + 'Reference3' => $this->getReference3(), + 'Reference4' => $this->getReference4(), + 'Reference5' => $this->getReference5() + ]; + } + + /** + * @param $obj + * @return Transaction + */ + public static function parse($obj) + { + if (!$obj) + return new self(); + + return (new self()) + ->setReference1($obj->Reference1) + ->setReference2($obj->Reference2) + ->setReference3($obj->Reference3) + ->setReference4($obj->Reference4) + ->setReference5($obj->Reference4); + } +} \ No newline at end of file diff --git a/src/API/Classes/Volume.php b/src/API/Classes/Volume.php new file mode 100644 index 0000000..31495c1 --- /dev/null +++ b/src/API/Classes/Volume.php @@ -0,0 +1,85 @@ +unit; + } + + /** + * Unit of the volume + * Options: Cm3, Inch3 + * + * @param string $unit + * @return $this + */ + public function setUnit(string $unit) + { + $this->unit = $unit; + return $this; + } + + /** + * @return float + */ + public function getValue(): float + { + return $this->value; + } + + /** + * Shipment Volume + * + * @param float $value + * @return $this + */ + public function setValue(float $value) + { + $this->value = $value; + return $this; + } + + /** + * Centimeters + * @return Volume + */ + public function useCentimetersAsUnit() + { + return $this->setUnit('Cm3'); + } + + /** + * Inches + * @return Volume + */ + public function useInchesAsUnit() + { + return $this->setUnit('Inch3'); + } + + public function normalize(): array + { + return [ + 'Unit' => $this->getUnit(), + 'Value' => $this->getValue() + ]; + } +} \ No newline at end of file diff --git a/src/API/Classes/Weight.php b/src/API/Classes/Weight.php new file mode 100644 index 0000000..ee2de65 --- /dev/null +++ b/src/API/Classes/Weight.php @@ -0,0 +1,83 @@ +unit; + } + + /** + * Unit of the weight + * @param string $unit + * @return $this + */ + public function setUnit(string $unit) + { + $this->unit = $unit; + return $this; + } + + /** + * @return float + */ + public function getValue() + { + return $this->value; + } + + /** + * Shipment weight. + * If the Data Entity ‘Dimensions’ are filled, charging weight is compared to actual and the highest value is filled here. + * @param float $value + * @return $this + */ + public function setValue(float $value) + { + $this->value = $value; + return $this; + } + + /** + * Kilogram + * @return Weight + */ + public function useKilogramAsUnit() + { + return $this->setUnit('KG'); + } + + /** + * Pound + * @return Weight + */ + public function usePoundAsUnit() + { + return $this->setUnit('LB'); + } + + public function normalize(): array + { + return [ + 'Unit' => $this->getUnit(), + 'Value' => $this->getValue() + ]; + } +} \ No newline at end of file diff --git a/src/API/Interfaces/Normalize.php b/src/API/Interfaces/Normalize.php new file mode 100644 index 0000000..4eb013b --- /dev/null +++ b/src/API/Interfaces/Normalize.php @@ -0,0 +1,10 @@ +useLiveAsEnvironment() : $this->useTestAsEnvironment(); + + $this->fillClientInfoFromEnv(); + + $this->soapClient = new \SoapClient($this->getWsdlAccordingToEnvironment(), array('trace' => 1)); + } + + public function setClientInfo(ClientInfo $clientInfo) + { + $this->clientInfo = $clientInfo; + return $this; + } + + /** + * @return ClientInfo + */ + public function getClientInfo() + { + return $this->clientInfo; + } + + /** + * @return Transaction + */ + public function getTransaction() + { + return $this->transaction; + } + + /** + * @param $transaction + * @return $this + */ + public function setTransaction(Transaction $transaction) + { + $this->transaction = $transaction; + return $this; + } + + /** + * @param $environment + * @return $this + */ + protected function setEnvironment($environment) + { + $this->environment = $environment; + return $this; + } + + public function useTestAsEnvironment() + { + return $this->setEnvironment('test'); + } + + public function useLiveAsEnvironment() + { + return $this->setEnvironment('live'); + } + + /** + * @return bool + */ + public function isTest() + { + return $this->environment === "test"; + } + + /** + * @return bool + */ + public function isLive() + { + return $this->environment === "live"; + } + + /** + * @return string + */ + protected function getWsdlAccordingToEnvironment() + { + if ($this->isLive()) { + return $this->live_wsdl; + } else { + return $this->test_wsdl; + } + } + + /** + * @throws \Exception + */ + protected function validate() + { + if (!$this->clientInfo) { + throw new \Exception('Client Info Not Provided'); + } + } + + /** + * @return $this + */ + private function fillClientInfoFromEnv() + { + $this->clientInfo = (new ClientInfo()) + ->setAccountCountryCode(config("aramex.$this->environment.country_code")) + ->setAccountEntity(config("aramex.$this->environment.entity")) + ->setAccountNumber(config("aramex.$this->environment.number")) + ->setAccountPin(config("aramex.$this->environment.pin")) + ->setUserName(config("aramex.$this->environment.username")) + ->setPassword(config("aramex.$this->environment.password")); + + return $this; + } + + public function getAccountNumber() + { + return config("aramex.$this->environment.number"); + } + + public function normalize(): array + { + return [ + 'ClientInfo' => $this->getClientInfo()->normalize(), + 'Transaction' => optional($this->getTransaction())->normalize() + ]; + } +} \ No newline at end of file diff --git a/src/API/Requests/Location/FetchCities.php b/src/API/Requests/Location/FetchCities.php new file mode 100644 index 0000000..76c11ca --- /dev/null +++ b/src/API/Requests/Location/FetchCities.php @@ -0,0 +1,95 @@ +validate(); + + return CitiesFetchingResponse::make($this->soapClient->FetchCities($this->normalize())); + } + + /** + * @return string + */ + public function getCountryCode(): ?string + { + return $this->countryCode; + } + + /** + * @param string $countryCode + */ + public function setCountryCode(string $countryCode): FetchCities + { + $this->countryCode = $countryCode; + return $this; + } + + /** + * @return string|null + */ + public function getState(): ?string + { + return $this->state; + } + + /** + * @param string|null $state + */ + public function setState(?string $state): FetchCities + { + $this->state = $state; + return $this; + } + + /** + * @return string|null + */ + public function getNameStartsWith(): ?string + { + return $this->nameStartsWith; + } + + /** + * @param string|null $nameStartsWith + */ + public function setNameStartsWith(?string $nameStartsWith): FetchCities + { + $this->nameStartsWith = $nameStartsWith; + return $this; + } + + public function normalize(): array + { + return array_merge([ + 'CountryCode' => $this->getCountryCode(), + 'State' => $this->getState(), + 'NameStartsWith' => $this->getNameStartsWith(), + ], parent::normalize()); + } +} \ No newline at end of file diff --git a/src/API/Requests/Location/FetchCountries.php b/src/API/Requests/Location/FetchCountries.php new file mode 100644 index 0000000..b6893f0 --- /dev/null +++ b/src/API/Requests/Location/FetchCountries.php @@ -0,0 +1,28 @@ +validate(); + + return CountriesFetchingResponse::make($this->soapClient->FetchCountries($this->normalize())); + } + + public function normalize(): array + { + return parent::normalize(); + } +} \ No newline at end of file diff --git a/src/API/Requests/Location/FetchCountry.php b/src/API/Requests/Location/FetchCountry.php new file mode 100644 index 0000000..76e2788 --- /dev/null +++ b/src/API/Requests/Location/FetchCountry.php @@ -0,0 +1,60 @@ +validate(); + + return CountryFetchingResponse::make($this->soapClient->FetchCountry($this->normalize())); + } + + protected function validate() + { + parent::validate(); + + if (!$this->code) { + throw new Exception('Should provide country code!'); + } + } + + /** + * @return string + */ + public function getCode(): string + { + return $this->code; + } + + /** + * @param string $code + */ + public function setCode(string $code): FetchCountry + { + $this->code = $code; + return $this; + } + + + public function normalize(): array + { + return array_merge([ + 'Code' => $this->getCode() + ], parent::normalize()); + } +} \ No newline at end of file diff --git a/src/API/Requests/Location/FetchDropOffLocations.php b/src/API/Requests/Location/FetchDropOffLocations.php new file mode 100644 index 0000000..7b49d90 --- /dev/null +++ b/src/API/Requests/Location/FetchDropOffLocations.php @@ -0,0 +1,22 @@ +validate(); + + return OfficesFetchingResponse::make($this->soapClient->FetchOffices($this->normalize())); + } + + protected function validate() + { + parent::validate(); + + if (!$this->countryCode) { + throw new Exception('Should provide country code!'); + } + } + + /** + * @return string + */ + public function getCountryCode(): string + { + return $this->countryCode; + } + + /** + * @param string $countryCode + */ + public function setCountryCode(string $countryCode): FetchOffices + { + $this->countryCode = $countryCode; + return $this; + } + + + public function normalize(): array + { + return array_merge([ + 'CountryCode' => $this->getCountryCode() + ], parent::normalize()); + } +} \ No newline at end of file diff --git a/src/API/Requests/Location/FetchStates.php b/src/API/Requests/Location/FetchStates.php new file mode 100644 index 0000000..8fc1e9a --- /dev/null +++ b/src/API/Requests/Location/FetchStates.php @@ -0,0 +1,60 @@ +validate(); + + return StatesFetchingResponse::make($this->soapClient->FetchStates($this->normalize())); + } + + protected function validate() + { + parent::validate(); + + if (!$this->countryCode) { + throw new Exception('Should provide country code!'); + } + } + + /** + * @return string + */ + public function getCountryCode(): string + { + return $this->countryCode; + } + + /** + * @param string $countryCode + */ + public function setCountryCode(string $countryCode): FetchStates + { + $this->countryCode = $countryCode; + return $this; + } + + + public function normalize(): array + { + return array_merge([ + 'CountryCode' => $this->getCountryCode() + ], parent::normalize()); + } +} \ No newline at end of file diff --git a/src/API/Requests/Location/ValidateAddress.php b/src/API/Requests/Location/ValidateAddress.php new file mode 100644 index 0000000..f990c83 --- /dev/null +++ b/src/API/Requests/Location/ValidateAddress.php @@ -0,0 +1,69 @@ +validate(); + + dd($this->soapClient->ValidateAddress($this->normalize())); + return AddressValidationResponse::make($this->soapClient->ValidateAddress($this->normalize())); + } + + public function validate() + { + parent::validate(); + + if (!$this->address) { + throw new \Exception('Address should be provided.!'); + } + + } + + /** + * @return Address + */ + public function getAddress(): Address + { + return $this->address; + } + + /** + * @param Address $address + */ + public function setAddress(Address $address): ValidateAddress + { + $this->address = $address; + return $this; + } + + + public function normalize(): array + { + return array_merge([ + 'Address' => $this->getAddress()->normalize() + ], parent::normalize()); + } +} \ No newline at end of file diff --git a/src/API/Requests/Rate/CalculateRate.php b/src/API/Requests/Rate/CalculateRate.php new file mode 100644 index 0000000..5707a69 --- /dev/null +++ b/src/API/Requests/Rate/CalculateRate.php @@ -0,0 +1,141 @@ +validate(); + + return RateCalculatorResponse::make($this->soapClient->CalculateRate($this->normalize())); + } + + protected function validate() + { + Parent::validate(); + + if (!$this->originalAddress) { + throw new \Exception('Origin Address not provided'); + } + + if (!$this->destinationAddress) { + throw new \Exception('Destination Address not provided'); + } + + if (!$this->shipmentDetails) { + throw new \Exception('Shipment Details not provided'); + } + } + + /** + * @return Address + */ + public function getOriginalAddress(): Address + { + return $this->originalAddress; + } + + /** + * To identify the desired physical shipment origin location details + * and validates them to be a factor in rate calculation. + * + * @param Address $originalAddress + * @return $this + */ + public function setOriginalAddress(Address $originalAddress): CalculateRate + { + $this->originalAddress = $originalAddress; + return $this; + } + + /** + * @return Address + */ + public function getDestinationAddress(): Address + { + return $this->destinationAddress; + } + + /** + * To identify the desired shipment Destination location details + * and validates them to be a factor in rate calculation. + * + * @param Address $destinationAddress + * @return $this + */ + public function setDestinationAddress(Address $destinationAddress): CalculateRate + { + $this->destinationAddress = $destinationAddress; + return $this; + } + + /** + * @return ShipmentDetails + */ + public function getShipmentDetails(): ShipmentDetails + { + return $this->shipmentDetails; + } + + /** + * Several aspects about the shipment some required to be filled, + * other aspects are optional if the customer wished to include extra features. + * + * @param ShipmentDetails $shipmentDetails + * @return $this + */ + public function setShipmentDetails(ShipmentDetails $shipmentDetails): CalculateRate + { + $this->shipmentDetails = $shipmentDetails; + return $this; + } + + + /** + * @return string + */ + public function getPreferredCurrencyCode(): ?string + { + return $this->preferredCurrencyCode; + } + + /** + * @param string $preferredCurrencyCode + * @return $this + */ + public function setPreferredCurrencyCode(string $preferredCurrencyCode): CalculateRate + { + $this->preferredCurrencyCode = $preferredCurrencyCode; + return $this; + } + + public function normalize(): array + { + return array_merge([ + 'OriginAddress' => $this->getOriginalAddress()->normalize(), + 'DestinationAddress' => $this->getDestinationAddress()->normalize(), + 'ShipmentDetails' => $this->getShipmentDetails()->normalize(), + 'PreferredCurrencyCode' => $this->getPreferredCurrencyCode() + ], parent::normalize()); + } + +} \ No newline at end of file diff --git a/src/API/Requests/Shipping/CancelPickup.php b/src/API/Requests/Shipping/CancelPickup.php new file mode 100644 index 0000000..3e22190 --- /dev/null +++ b/src/API/Requests/Shipping/CancelPickup.php @@ -0,0 +1,90 @@ +validate(); + + return PickupCancellationResponse::make($this->soapClient->CancelPickup($this->normalize())); + } + + /** + * @throws \Exception + */ + protected function validate() + { + parent::validate(); + + if (!$this->pickupGUID) { + throw new \Exception('PickupGUID Not Provided'); + } + } + + /** + * @return string + */ + public function getPickupGUID(): string + { + return $this->pickupGUID; + } + + /** + * @param string $pickupGUID + * @return CancelPickup + */ + public function setPickupGUID(string $pickupGUID): CancelPickup + { + $this->pickupGUID = $pickupGUID; + return $this; + } + + /** + * @return string|null + */ + public function getComments(): ?string + { + return $this->comments; + } + + /** + * @param string $comments + * @return CancelPickup + */ + public function setComments(string $comments = null): CancelPickup + { + $this->comments = $comments; + return $this; + } + + public function normalize(): array + { + return array_merge([ + 'PickupGUID' => $this->getPickupGUID(), + 'Comments' => $this->getComments(), + ], parent::normalize()); + } +} \ No newline at end of file diff --git a/src/API/Requests/Shipping/CreatePickup.php b/src/API/Requests/Shipping/CreatePickup.php new file mode 100644 index 0000000..f107d0d --- /dev/null +++ b/src/API/Requests/Shipping/CreatePickup.php @@ -0,0 +1,81 @@ +validate(); + + return PickupCreationResponse::make($this->soapClient->CreatePickup($this->normalize())); + } + + /** + * @return Pickup + */ + public function getPickup() + { + return $this->pickup; + } + + /** + * @param Pickup $pickup + * @return $this + */ + public function setPickup(Pickup $pickup) + { + $this->pickup = $pickup; + 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([ + 'Pickup' => $this->getPickup()->normalize(), + 'LabelInfo' => optional($this->getLabelInfo())->normalize(), + ], parent::normalize()); + } +} \ No newline at end of file diff --git a/src/API/Requests/Shipping/CreateShipments.php b/src/API/Requests/Shipping/CreateShipments.php new file mode 100644 index 0000000..5f5a215 --- /dev/null +++ b/src/API/Requests/Shipping/CreateShipments.php @@ -0,0 +1,103 @@ +validate(); + + return ShipmentCreationResponse::make($this->soapClient->CreateShipments($this->normalize())); + } + + protected function validate() + { + parent::validate(); + + if (!$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) { + /** @var Shipment $item */ + return $item->normalize(); + }, $this->getShipments()) : [], + 'LabelInfo' => optional($this->getLabelInfo())->normalize(), + ], parent::normalize()); + } +} \ No newline at end of file diff --git a/src/API/Requests/Shipping/GetLastShipmentsNumbersRange.php b/src/API/Requests/Shipping/GetLastShipmentsNumbersRange.php new file mode 100644 index 0000000..697fe56 --- /dev/null +++ b/src/API/Requests/Shipping/GetLastShipmentsNumbersRange.php @@ -0,0 +1,97 @@ +validate(); + + dd($this->soapClient->GetLastShipmentsNumbersRange($this->normalize())); + + return LastReservedShipmentNumberRangeResponse::make($this->soapClient->GetLastShipmentsNumbersRange($this->normalize())); + } + + /** + * @throws \Exception + */ + protected function validate() + { + parent::validate(); + + if (!$this->entity) { + throw new \Exception('Entity Not Provided'); + } + + if (!$this->productGroup) { + throw new \Exception('Product Group Not Provided'); + } + } + + /** + * @return string + */ + public function getEntity(): string + { + return $this->entity; + } + + /** + * @param string $entity + * @return LastReserveShipmentNumberRange + */ + public function setEntity(string $entity): GetLastShipmentsNumbersRange + { + $this->entity = $entity; + + return $this; + } + + /** + * @return string + */ + public function getProductGroup(): string + { + return $this->productGroup; + } + + /** + * @param string $productGroup + * @return LastReserveShipmentNumberRange + */ + public function setProductGroup(string $productGroup): GetLastShipmentsNumbersRange + { + $this->productGroup = $productGroup; + return $this; + } + + public function normalize(): array + { + return array_merge([ + 'Entity' => $this->getEntity(), + 'ProductGroup' => $this->getProductGroup() + ], parent::normalize()); + } +} \ No newline at end of file diff --git a/src/API/Requests/Shipping/PrintLabel.php b/src/API/Requests/Shipping/PrintLabel.php new file mode 100644 index 0000000..18695f0 --- /dev/null +++ b/src/API/Requests/Shipping/PrintLabel.php @@ -0,0 +1,138 @@ +validate(); + + return LabelPrintingResponse::make($this->soapClient->PrintLabel($this->normalize())); + } + + /** + * @throws \Exception + */ + protected function validate() + { + parent::validate(); + + if (!$this->shipmentNumber) { + throw new \Exception('Shipment Number Not Provided'); + } + + if (!$this->labelInfo) { + throw new \Exception('Label Info Not Provided'); + } + } + + /** + * @return string + */ + public function getShipmentNumber(): string + { + return $this->shipmentNumber; + } + + /** + * @param string $shipmentNumber + * @return PrintLabel + */ + public function setShipmentNumber(string $shipmentNumber): PrintLabel + { + $this->shipmentNumber = $shipmentNumber; + return $this; + } + + /** + * @return string|null + */ + public function getProductGroup(): ?string + { + return $this->productGroup; + } + + /** + * @param string $productGroup + * @return PrintLabel + */ + public function setProductGroup(string $productGroup = null): PrintLabel + { + $this->productGroup = $productGroup; + return $this; + } + + /** + * @return string|null + */ + public function getOriginEntity(): ?string + { + return $this->originEntity; + } + + /** + * @param string $originEntity + * @return PrintLabel + */ + public function setOriginEntity(string $originEntity = null): PrintLabel + { + $this->originEntity = $originEntity; + return $this; + } + + /** + * @return LabelInfo + */ + public function getLabelInfo(): LabelInfo + { + return $this->labelInfo; + } + + /** + * @param LabelInfo $labelInfo + * @return PrintLabel + */ + public function setLabelInfo(LabelInfo $labelInfo): PrintLabel + { + $this->labelInfo = $labelInfo; + return $this; + } + + public function normalize(): array + { + return array_merge([ + 'ShipmentNumber' => $this->getShipmentNumber(), + 'ProductGroup' => $this->getProductGroup(), + 'OriginEntity' => $this->getOriginEntity(), + 'LabelInfo' => optional($this->getLabelInfo())->normalize(), + ], parent::normalize()); + } +} \ No newline at end of file diff --git a/src/API/Requests/Shipping/ReserveShipmentNumberRange.php b/src/API/Requests/Shipping/ReserveShipmentNumberRange.php new file mode 100644 index 0000000..734bc38 --- /dev/null +++ b/src/API/Requests/Shipping/ReserveShipmentNumberRange.php @@ -0,0 +1,130 @@ +validate(); + + return ReserveRangeResponse::make($this->soapClient->ReserveShipmentNumberRange($this->normalize())); + } + + /** + * @throws \Exception + */ + protected function validate() + { + parent::validate(); + + if (!$this->entity) { + throw new \Exception('Entity Not Provided'); + } + + if (!$this->productGroup) { + throw new \Exception('Product Group Not Provided'); + } + + if (!$this->productGroup) { + throw new \Exception('Count Not Provided'); + } + } + + /** + * @return string + */ + public function getEntity(): string + { + return $this->entity; + } + + /** + * This data should be provided to you from your Aramex representative. + * Allowed Values: + * Example: LON for London station + * + * @param string $entity + * @return ReserveRange + */ + public function setEntity(string $entity): ReserveShipmentNumberRange + { + $this->entity = $entity; + return $this; + } + + /** + * @return string + */ + public function getProductGroup(): string + { + return $this->productGroup; + } + + /** + * Allowed Values: + * EXP = Express + * DOM = Domestic + * + * @param string $productGroup + * @return ReserveRange + */ + public function setProductGroup(string $productGroup): ReserveShipmentNumberRange + { + $this->productGroup = $productGroup; + return $this; + } + + /** + * @return int + */ + public function getCount(): int + { + return $this->count; + } + + /** + * The range of shipment numbers to be reserved and used to send CreateShipment requests + * Allowed Values: 1-5000 + * + * @param int $count + * @return ReserveRange + */ + public function setCount(int $count): ReserveShipmentNumberRange + { + $this->count = $count; + return $this; + } + + public function normalize(): array + { + return array_merge([ + 'Entity' => $this->getEntity(), + 'ProductGroup' => $this->getProductGroup(), + 'Count' => $this->getCount() + ], parent::normalize()); + } + +} \ No newline at end of file diff --git a/src/API/Requests/Shipping/ScheduleDelivery.php b/src/API/Requests/Shipping/ScheduleDelivery.php new file mode 100644 index 0000000..be6f77a --- /dev/null +++ b/src/API/Requests/Shipping/ScheduleDelivery.php @@ -0,0 +1,243 @@ +validate(); + + return ScheduledDeliveryResponse::make($this->soapClient->ScheduleDelivery($this->normalize())); + } + + /** + * @return Address + */ + public function getAddress(): Address + { + return $this->address; + } + + /** + * @param Address $address + * @return ScheduledDelivery + */ + public function setAddress(Address $address): ScheduledDelivery + { + $this->address = $address; + return $this; + } + + /** + * @return Resource + */ + public function getScheduledDelivery(): Resource + { + return $this->scheduledDelivery; + } + + /** + * @param mixed $scheduledDelivery + * @return ScheduledDelivery + */ + public function setScheduledDelivery($scheduledDelivery): ScheduledDelivery + { + $this->scheduledDelivery = $scheduledDelivery; + return $this; + } + + /** + * @return string + */ + public function getShipmentNumber(): string + { + return $this->shipmentNumber; + } + + /** + * @param string $shipmentNumber + * @return ScheduledDelivery + */ + public function setShipmentNumber(string $shipmentNumber): ScheduledDelivery + { + $this->shipmentNumber = $shipmentNumber; + return $this; + } + + /** + * @return string + */ + public function getProductGroup(): string + { + return $this->productGroup; + } + + /** + * @param string $productGroup + * @return ScheduledDelivery + */ + public function setProductGroup(string $productGroup): ScheduledDelivery + { + $this->productGroup = $productGroup; + return $this; + } + + /** + * @return string + */ + public function getEntity(): string + { + return $this->entity; + } + + /** + * @param string $entity + * @return ScheduledDelivery + */ + public function setEntity(string $entity): ScheduledDelivery + { + $this->entity = $entity; + return $this; + } + + /** + * @return string + */ + public function getConsigneePhone(): string + { + return $this->consigneePhone; + } + + /** + * @param string $consigneePhone + * @return ScheduledDelivery + */ + public function setConsigneePhone(string $consigneePhone): ScheduledDelivery + { + $this->consigneePhone = $consigneePhone; + return $this; + } + + /** + * @return string + */ + public function getShipperNumber(): string + { + return $this->shipperNumber; + } + + /** + * @param string $shipperNumber + * @return ScheduledDelivery + */ + public function setShipperNumber(string $shipperNumber): ScheduledDelivery + { + $this->shipperNumber = $shipperNumber; + return $this; + } + + /** + * @return string + */ + public function getShipperReference(): string + { + return $this->shipperReference; + } + + /** + * @param string $shipperReference + * @return ScheduledDelivery + */ + public function setShipperReference(string $shipperReference): ScheduledDelivery + { + $this->shipperReference = $shipperReference; + return $this; + } + + /** + * @return string + */ + public function getReference1(): string + { + return $this->reference1; + } + + /** + * @param string $reference1 + * @return ScheduledDelivery + */ + public function setReference1(string $reference1): ScheduledDelivery + { + $this->reference1 = $reference1; + return $this; + } + + /** + * @return string + */ + public function getReference2(): string + { + return $this->reference2; + } + + /** + * @param string $reference2 + * @return ScheduledDelivery + */ + public function setReference2(string $reference2) + { + $this->reference2 = $reference2; + return $this; + } + + /** + * @return string + */ + public function getReference3(): string + { + return $this->reference3; + } + + /** + * @param string $reference3 + * @return ScheduledDelivery + */ + public function setReference3(string $reference3): ScheduledDelivery + { + $this->reference3 = $reference3; + return $this; + } +} \ No newline at end of file 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()); + } +} + + diff --git a/src/API/Requests/Tracking/TrackPickup.php b/src/API/Requests/Tracking/TrackPickup.php new file mode 100644 index 0000000..99f5830 --- /dev/null +++ b/src/API/Requests/Tracking/TrackPickup.php @@ -0,0 +1,109 @@ +validate(); + + return PickupTrackingResponse::make($this->soapClient->TrackPickup($this->normalize())); + } + + protected function validate() + { + if (!$this->reference) { + throw new \Exception('Reference is not provided'); + } + + if (!$this->pickup) { + throw new \Exception('Pickup is not provided'); + } + } + + /** + * @return array + */ + public function getShipments() + { + return $this->shipments; + } + + /** + * @param array $shipments + * @return TrackPickup + */ + public function setShipments(array $shipments): TrackPickup + { + $this->shipments = $shipments; + return $this; + } + + /** + * @param string $shipment + * @return TrackPickup + */ + public function addShipment(string $shipment): TrackPickup + { + $this->shipments[] = $shipment; + return $this; + } + + /** + * @return string + */ + public function getReference(): string + { + return $this->reference; + } + + /** + * @param mixed $reference + * @return TrackPickup + */ + public function setReference($reference): TrackPickup + { + $this->reference = $reference; + return $this; + } + + /** + * @return mixed + */ + public function getPickup() + { + return $this->pickup; + } + + /** + * @param mixed $pickup + * @return TrackPickup + */ + public function setPickup($pickup): TrackPickup + { + $this->pickup = $pickup; + return $this; + } + + public function normalize(): array + { + return array_merge([ + 'Shipments' => $this->getShipments(), + 'Reference' => $this->getReference(), + 'Pickup' => $this->getPickup(), + ], parent::normalize()); + } + +} \ No newline at end of file diff --git a/src/API/Requests/Tracking/TrackShipments.php b/src/API/Requests/Tracking/TrackShipments.php new file mode 100644 index 0000000..164162b --- /dev/null +++ b/src/API/Requests/Tracking/TrackShipments.php @@ -0,0 +1,93 @@ +validate(); + + return ShipmentTrackingResponse::make($this->soapClient->TrackShipments($this->normalize())); + } + + protected function validate() + { + parent::validate(); + + if (!$this->shipments) { + throw new \Exception('Shipments are not provided'); + } + } + + /** + * @return bool + */ + public function getGetLastTrackingUpdateOnly(): ?bool + { + return $this->getLastTrackingUpdateOnly; + } + + /** + * @param bool $getLastTrackingUpdateOnly + * @return TrackShipments + */ + public function setGetLastTrackingUpdateOnly(bool $getLastTrackingUpdateOnly = null): TrackShipments + { + $this->getLastTrackingUpdateOnly = $getLastTrackingUpdateOnly; + return $this; + } + + /** + * @return string[] + */ + public function getShipments(): array + { + return $this->shipments; + } + + /** + * @param string[] $shipments + * @return TrackShipments + */ + public function setShipments(array $shipments): TrackShipments + { + $this->shipments = $shipments; + return $this; + } + + /** + * @param string $shipment + * @return TrackShipments + */ + public function addShipment(string $shipment): TrackShipments + { + $this->shipments[] = $shipment; + return $this; + } + + public function normalize(): array + { + return array_merge([ + 'Shipments' => $this->getShipments(), + 'GetLastTrackingUpdateOnly' => $this->getGetLastTrackingUpdateOnly() + ], parent::normalize()); + } + +} \ No newline at end of file diff --git a/src/API/Response/Location/AddressValidationResponse.php b/src/API/Response/Location/AddressValidationResponse.php new file mode 100644 index 0000000..45ec3a0 --- /dev/null +++ b/src/API/Response/Location/AddressValidationResponse.php @@ -0,0 +1,68 @@ +suggestedAddresses; + } + + /** + * @param Address[] $suggestedAddresses + */ + public function setSuggestedAddresses(array $suggestedAddresses): AddressValidationResponse + { + $this->suggestedAddresses = $suggestedAddresses; + return $this; + } + + /** + * @param Address $suggestedAddresses + */ + public function addSuggestedAddresses(Address $suggestedAddress): AddressValidationResponse + { + $this->suggestedAddresses[] = $suggestedAddress; + return $this; + } + + /** + * @param object $obj + * @return self + */ + protected function parse($obj) + { + parent::parse($obj); + + // todo + // Add Suggested Addresses + + return $this; + } + + /** + * @param object $obj + * @return RateResponse + */ + public static function make($obj) + { + return (new self())->parse($obj); + } + +} \ No newline at end of file diff --git a/src/API/Response/Location/CitiesFetchingResponse.php b/src/API/Response/Location/CitiesFetchingResponse.php new file mode 100644 index 0000000..e33a4f6 --- /dev/null +++ b/src/API/Response/Location/CitiesFetchingResponse.php @@ -0,0 +1,65 @@ +cities; + } + + /** + * @param string[] $cities + * @return $this + */ + public function setCities(array $cities): CitiesFetchingResponse + { + $this->cities = $cities; + return $this; + } + + /** + * @param string $city + * @return $this + */ + public function addCity(string $city): CitiesFetchingResponse + { + $this->cities[] = $city; + return $this; + } + + /** + * @param object $obj + * @return self + */ + protected function parse($obj) + { + parent::parse($obj); + + if ($obj->Cities && property_exists($obj->Cities, 'string') && is_array($obj->Cities->string)) { + $this->setCities($obj->Cities->string); + } elseif ($obj->Cities && property_exists($obj->Cities, 'string') && is_string($obj->Cities->string)) { + $this->setCities([$obj->Cities->string]); + } + + return $this; + } + + /** + * @param object $obj + * @return RateResponse + */ + public static function make($obj) + { + return (new self())->parse($obj); + } +} \ No newline at end of file diff --git a/src/API/Response/Location/CountriesFetchingResponse.php b/src/API/Response/Location/CountriesFetchingResponse.php new file mode 100644 index 0000000..a6b8cf3 --- /dev/null +++ b/src/API/Response/Location/CountriesFetchingResponse.php @@ -0,0 +1,74 @@ +countries; + } + + /** + * @param Country[] $countries + * @return $this + */ + public function setCountries(array $countries): CountriesFetchingResponse + { + $this->countries = $countries; + return $this; + } + + /** + * @param Country $country + * @return $this + */ + public function addCountry(Country $country): CountriesFetchingResponse + { + $this->countries[] = $country; + return $this; + } + + /** + * @param object $obj + * @return self + */ + protected function parse($obj) + { + parent::parse($obj); + + if (is_array($obj->Countries->Country)) { + foreach ($obj->Countries->Country as $country) { + $this->addCountry( + (new Country()) + ->setCode($country->Code) + ->setName($country->Name) + ->setIsoCode($country->IsoCode) + ->setStateRequired($country->StateRequired) + ->setPostCodeRequired($country->PostCodeRequired) + ->setInternationalCallingNumber($country->InternationalCallingNumber) + ); + } + } + + return $this; + } + + /** + * @param object $obj + * @return RateResponse + */ + public static function make($obj) + { + return (new self())->parse($obj); + } + +} \ No newline at end of file diff --git a/src/API/Response/Location/CountryFetchingResponse.php b/src/API/Response/Location/CountryFetchingResponse.php new file mode 100644 index 0000000..4cd41f8 --- /dev/null +++ b/src/API/Response/Location/CountryFetchingResponse.php @@ -0,0 +1,61 @@ +country; + } + + /** + * @param Country $country + * @return $this + */ + public function setCountry(Country $country): CountryFetchingResponse + { + $this->country = $country; + return $this; + } + + /** + * @param object $obj + * @return self + */ + protected function parse($obj) + { + parent::parse($obj); + + if ($country = $obj->Country){ + $this->setCountry( + (new Country()) + ->setCode($country->Code) + ->setName($country->Name) + ->setIsoCode($country->IsoCode) + ->setStateRequired($country->StateRequired) + ->setPostCodeRequired($country->PostCodeRequired) + ->setInternationalCallingNumber($country->InternationalCallingNumber) + ); + } + + return $this; + } + + /** + * @param object $obj + * @return RateResponse + */ + public static function make($obj) + { + return (new self())->parse($obj); + } +} \ No newline at end of file diff --git a/src/API/Response/Location/DropOffLocationsFetchingResponse.php b/src/API/Response/Location/DropOffLocationsFetchingResponse.php new file mode 100644 index 0000000..ee90061 --- /dev/null +++ b/src/API/Response/Location/DropOffLocationsFetchingResponse.php @@ -0,0 +1,81 @@ +offices; + } + + /** + * @param Office[] $offices + * @return $this + */ + public function setOffices(array $offices): OfficesFetchingResponse + { + $this->offices = $offices; + return $this; + } + + /** + * @param Office $office + * @return $this + */ + public function addOffice(Office $office): OfficesFetchingResponse + { + $this->offices[] = $office; + return $this; + } + + /** + * @param object $obj + * @return self + */ + protected function parse($obj) + { + parent::parse($obj); + + + if (is_array($obj->Locations->DropOffLocation)) { + 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) + ); + } + } + + return $this; + } + + /** + * @param object $obj + * @return RateResponse + */ + public static function make($obj) + { + return (new self())->parse($obj); + } +} \ No newline at end of file diff --git a/src/API/Response/Location/OfficesFetchingResponse.php b/src/API/Response/Location/OfficesFetchingResponse.php new file mode 100644 index 0000000..30a09f4 --- /dev/null +++ b/src/API/Response/Location/OfficesFetchingResponse.php @@ -0,0 +1,117 @@ +offices; + } + + /** + * @param Office[] $offices + * @return $this + */ + public function setOffices(array $offices): OfficesFetchingResponse + { + $this->offices = $offices; + return $this; + } + + /** + * @param Office $office + * @return $this + */ + public function addOffice(Office $office): OfficesFetchingResponse + { + $this->offices[] = $office; + return $this; + } + + /** + * @param object $obj + * @return self + */ + protected function parse($obj) + { + parent::parse($obj); + + if (is_array($obj->Offices->Office)) { + + foreach ($obj->Offices->Office as $office) { + + if (property_exists($office, 'Address')) { + $addressObj = $office->Address; + + $officeAddress = new Address(); + $officeAddress + ->setLine1($addressObj->Line1) + ->setLine2($addressObj->Line2) + ->setLine3($addressObj->Line3) + ->setCity($addressObj->City) + ->setStateOrProvinceCode($addressObj->StateOrProvinceCode) + ->setPostCode($addressObj->PostCode) + ->setCountryCode($addressObj->CountryCode) + ->setLongitude($addressObj->Longitude) + ->setLatitude($addressObj->Latitude) + ->setBuildingNumber($addressObj->BuildingNumber) + ->setBuildingName($addressObj->BuildingName) + ->setFloor($addressObj->Floor) + ->setApartment($addressObj->Apartment) + ->setPOBox($addressObj->POBox) + ->setDescription($addressObj->Description); + } + + $officeObject = (new Office()) + ->setEntity($office->Entity) + ->setEntityDescription($office->EntityDescription) + ->setOfficeType($office->OfficeType) + ->setTelephone($office->Telephone) + ->setWorkingDays($office->WorkingDays) + ->setWorkingHours($office->WorkingHours) + ->setLongtitude($office->Longtitude) + ->setLatitude($office->Latitude); + + if (isset($addressObj)) { + $officeObject->setAddress($officeAddress); + } + + + $this->addOffice($officeObject); + } + } + + dd($this->offices); + return $this; + } + + public function objectToObject($instance, $className) + { + return unserialize(sprintf( + 'O:%d:"%s"%s', + strlen($className), + $className, + strstr(strstr(serialize($instance), '"'), ':') + )); + } + + /** + * @param object $obj + * @return RateResponse + */ + public static function make($obj) + { + return (new self())->parse($obj); + } +} \ No newline at end of file diff --git a/src/API/Response/Location/StatesFetchingResponse.php b/src/API/Response/Location/StatesFetchingResponse.php new file mode 100644 index 0000000..054101b --- /dev/null +++ b/src/API/Response/Location/StatesFetchingResponse.php @@ -0,0 +1,72 @@ +states; + } + + /** + * @param State[] $states + * @return $this + */ + public function setStates(array $states): StatesFetchingResponse + { + $this->states = $states; + return $this; + } + + /** + * @param State[] $state + * @return $this + */ + public function addState(State $state): StatesFetchingResponse + { + $this->states[] = $state; + return $this; + } + + /** + * @param object $obj + * @return self + */ + protected function parse($obj) + { + parent::parse($obj); + + if ($obj->States && property_exists($obj->States, 'State')) { + $states = $obj->States->State; + + foreach ($states as $state) { + $this->addState( + (new State()) + ->setCode($state->Code) + ->setName($state->Name) + ); + } + } + + return $this; + } + + /** + * @param object $obj + * @return RateResponse + */ + public static function make($obj) + { + return (new self())->parse($obj); + } + +} \ No newline at end of file diff --git a/src/API/Response/Rate/RateCalculatorResponse.php b/src/API/Response/Rate/RateCalculatorResponse.php new file mode 100644 index 0000000..a71b3f1 --- /dev/null +++ b/src/API/Response/Rate/RateCalculatorResponse.php @@ -0,0 +1,51 @@ +totalAmount; + } + + /** + * @param Money $totalAmount + * @return $this + */ + public function setTotalAmount(Money $totalAmount) + { + $this->totalAmount = $totalAmount; + return $this; + } + + /** + * @param object $obj + * @return self + */ + protected function parse($obj) + { + parent::parse($obj); + + $this->setTotalAmount(Money::parse($obj->TotalAmount)); + + return $this; + } + + /** + * @param object $obj + * @return RateResponse + */ + public static function make($obj) + { + return (new self())->parse($obj); + } +} \ No newline at end of file diff --git a/src/API/Response/Response.php b/src/API/Response/Response.php new file mode 100644 index 0000000..ac4723a --- /dev/null +++ b/src/API/Response/Response.php @@ -0,0 +1,120 @@ +transaction; + } + + /** + * @param Transaction $transaction + * @return $this + */ + public function setTransaction(Transaction $transaction) + { + $this->transaction = $transaction; + return $this; + } + + /** + * @return Notification[] + */ + public function getNotifications() + { + return $this->notifications; + } + + /** + * @param Notification[] $notifications + * @return $this + */ + public function setNotifications(array $notifications) + { + $this->notifications = $notifications; + return $this; + } + + /** + * @param Notification[] $notifications + * @return $this + */ + public function addNotifications(array $notifications) + { + $this->notifications = array_merge(($this->notifications ?? []), $notifications); + return $this; + } + + /** + * @return bool + */ + public function getHasErrors() + { + return $this->hasErrors; + } + + /** + * @param bool $hasErrors + * @return $this + */ + public function setHasErrors(bool $hasErrors) + { + $this->hasErrors = $hasErrors; + return $this; + } + + /** + * @return bool + */ + public function isSuccessful() + { + return !$this->hasErrors; + } + + public function getNotificationMessages() + { + return collect($this->getNotifications())->keyBy(function (Notification $notification) { + return $notification->getCode(); + })->map(function (Notification $notification) { + return $notification->getMessage(); + })->toArray(); + } + + public function getMessages() + { + return array_map(function (Notification $notification) { + return $notification->getMessage(); + }, $this->getNotifications()); + } + + /** + * @return bool + */ + public function isFail() + { + return $this->hasErrors; + } + + protected function parse($obj) + { + $this->setHasErrors($obj->HasErrors) + ->setTransaction(Transaction::parse($obj->Transaction)) + ->setNotifications(Notification::parseArray($obj->Notifications)); + + return $this; + } + + public static abstract function make($obj); +} \ No newline at end of file diff --git a/src/API/Response/Shipping/LabelPrintingResponse.php b/src/API/Response/Shipping/LabelPrintingResponse.php new file mode 100644 index 0000000..4b85e62 --- /dev/null +++ b/src/API/Response/Shipping/LabelPrintingResponse.php @@ -0,0 +1,87 @@ +shipmentNumber; + } + + /** + * @param string $shipmentNumber + * @return LabelPrintingResponse + */ + public function setShipmentNumber(string $shipmentNumber): LabelPrintingResponse + { + $this->shipmentNumber = $shipmentNumber; + return $this; + } + + /** + * @return ShipmentLabel + */ + public function getShipmentLabel(): ShipmentLabel + { + return $this->shipmentLabel; + } + + /** + * @param ShipmentLabel $shipmentLabel + * @return LabelPrintingResponse + */ + public function setShipmentLabel(ShipmentLabel $shipmentLabel): LabelPrintingResponse + { + $this->shipmentLabel = $shipmentLabel; + return $this; + } + + + /** + * @param object $obj + * @return self + */ + protected function parse($obj) + { + parent::parse($obj); + + $this->setShipmentNumber($obj->ShipmentNumber); + + if (property_exists($obj, 'ShipmentLabel') && $obj->ShipmentLabel != null) { + $this->setShipmentLabel( + (new ShipmentLabel()) + ->setLabelUrl($obj->ShipmentLabel->LabelURL) + ->setLabelFileContents($obj->ShipmentLabel->LabelFileContents) + ); + } + + return $this; + } + + /** + * @param object $obj + * @return LabelPrintingResponse + */ + public static function make($obj) + { + return (new self())->parse($obj); + } +} \ No newline at end of file diff --git a/src/API/Response/Shipping/LastReservedShipmentNumberRangeResponse.php b/src/API/Response/Shipping/LastReservedShipmentNumberRangeResponse.php new file mode 100644 index 0000000..0dc88f8 --- /dev/null +++ b/src/API/Response/Shipping/LastReservedShipmentNumberRangeResponse.php @@ -0,0 +1,76 @@ +fromWayBill; + } + + /** + * @param string $fromWayBill + * @return LastReservedShipmentNumberRangeResponse + */ + public function setFromWayBill(string $fromWayBill): LastReservedShipmentNumberRangeResponse + { + $this->fromWayBill = $fromWayBill; + return $this; + } + + /** + * @return string + */ + public function getToWayBill(): string + { + return $this->toWayBill; + } + + /** + * @param string $toWayBill + * @return LastReservedShipmentNumberRangeResponse + */ + public function setToWayBill($toWayBill): LastReservedShipmentNumberRangeResponse + { + $this->toWayBill = $toWayBill; + return $this; + } + + /** + * @param object $obj + * @return self + */ + protected function parse($obj) + { + parent::parse($obj); + + $this->setFromWayBill($obj->FromWayBill); + $this->setToWayBill($obj->ToWayBill); + + return $this; + } + + /** + * @param object $obj + * @return LastReservedShipmentNumberRangeResponse + */ + public static function make($obj) + { + return (new self())->parse($obj); + } +} \ No newline at end of file diff --git a/src/API/Response/Shipping/PickupCancellationResponse.php b/src/API/Response/Shipping/PickupCancellationResponse.php new file mode 100644 index 0000000..7681222 --- /dev/null +++ b/src/API/Response/Shipping/PickupCancellationResponse.php @@ -0,0 +1,55 @@ +message; + } + + /** + * @param string $message + */ + public function setMessage(string $message): PickupCancellationResponse + { + $this->message = $message; + return $this; + } + + /** + * @param object $obj + * @return self + */ + protected function parse($obj) + { + parent::parse($obj); + + $this->setMessage($obj->Message); + + return $this; + } + + /** + * @param object $obj + * @return PickupCancellationResponse + */ + public static function make($obj) + { + return (new self())->parse($obj); + } +} \ No newline at end of file diff --git a/src/API/Response/Shipping/PickupCreationResponse.php b/src/API/Response/Shipping/PickupCreationResponse.php new file mode 100644 index 0000000..9347885 --- /dev/null +++ b/src/API/Response/Shipping/PickupCreationResponse.php @@ -0,0 +1,73 @@ +precessedPickup; + } + + /** + * @param ProcessedPickup $precessedPickup + * @return PickupCreationResponse + */ + public function setPrecessedPickup(ProcessedPickup $precessedPickup): PickupCreationResponse + { + $this->precessedPickup = $precessedPickup; + return $this; + } + + /** + * @param object $obj + * @return self + */ + protected function parse($obj) + { + parent::parse($obj); + + $processedPickupObj = $obj->ProcessedPickup; + + $processedShipments = collect($processedPickupObj->ProcessedShipments)->toArray(); + + $processedPickup = new ProcessedPickup(); + $processedPickup = $processedPickup + ->setId($processedPickupObj->ID) + ->setGUID($processedPickupObj->GUID) + ->setReference1($processedPickupObj->Reference1) + ->setReference2($processedPickupObj->Reference2) + ->setProcessedShipments($processedShipments); + + $this->setPrecessedPickup($processedPickup); + + return $this; + } + + /** + * @param object $obj + * @return PickupCreationResponse + */ + public static function make($obj) + { + return (new self())->parse($obj); + } +} \ No newline at end of file diff --git a/src/API/Response/Shipping/ReserveRangeResponse.php b/src/API/Response/Shipping/ReserveRangeResponse.php new file mode 100644 index 0000000..feee0dd --- /dev/null +++ b/src/API/Response/Shipping/ReserveRangeResponse.php @@ -0,0 +1,77 @@ +fromWayBill; + } + + /** + * @param string $fromWayBill + * @return ReserveRangeResponse + */ + public function setFromWayBill(string $fromWayBill): ReserveRangeResponse + { + $this->fromWayBill = $fromWayBill; + return $this; + } + + /** + * @return string + */ + public function getToWayBill(): string + { + return $this->toWayBill; + } + + /** + * @param string $toWayBill + * @return ReserveRangeResponse + */ + public function setToWayBill($toWayBill): ReserveRangeResponse + { + $this->toWayBill = $toWayBill; + return $this; + } + + + /** + * @param object $obj + * @return self + */ + protected function parse($obj) + { + parent::parse($obj); + + $this->setFromWayBill($obj->FromWaybill); + $this->setToWayBill($obj->ToWaybill); + + return $this; + } + + /** + * @param object $obj + * @return ReserveRangeResponse + */ + public static function make($obj) + { + return (new self())->parse($obj); + } +} \ No newline at end of file diff --git a/src/API/Response/Shipping/ScheduledDeliveryResponse.php b/src/API/Response/Shipping/ScheduledDeliveryResponse.php new file mode 100644 index 0000000..ab050dd --- /dev/null +++ b/src/API/Response/Shipping/ScheduledDeliveryResponse.php @@ -0,0 +1,55 @@ +id; + } + + /** + * @param int $id + * @return ScheduledDeliveryResponse + */ + public function setId($id): ScheduledDeliveryResponse + { + $this->id = $id; + return $this; + } + + + /** + * @param object $obj + * @return self + */ + protected function parse($obj) + { + parent::parse($obj); + + return $this; + } + + /** + * @param object $obj + * @return ScheduledDeliveryResponse + */ + public static function make($obj) + { + return (new self())->parse($obj); + } +} \ No newline at end of file diff --git a/src/API/Response/Shipping/ShipmentCreationResponse.php b/src/API/Response/Shipping/ShipmentCreationResponse.php new file mode 100644 index 0000000..96a6399 --- /dev/null +++ b/src/API/Response/Shipping/ShipmentCreationResponse.php @@ -0,0 +1,66 @@ +shipments; + } + + + public function setShipments(array $shipments): ShipmentCreationResponse + { + $this->shipments = $shipments; + return $this; + } + + /** + * @param object $obj + * @return self + */ + protected function parse($obj) + { + parent::parse($obj); + + if ($obj->Shipments->ProcessedShipment->Notifications) { + $newNotifications = Notification::parseArray($obj->Shipments->ProcessedShipment->Notifications); + if ($newNotifications) { + $this->setHasErrors(true) + ->addNotifications($newNotifications); + } + } + + $this->setShipments([$obj->Shipments->ProcessedShipment]); + + return $this; + } + + /** + * @param object $obj + * @return ShipmentCreationResponse + */ + public static function make($obj) + { + return (new self())->parse($obj); + } +} \ No newline at end of file diff --git a/src/API/Response/Tracking/PickupTrackingResponse.php b/src/API/Response/Tracking/PickupTrackingResponse.php new file mode 100644 index 0000000..eb4f896 --- /dev/null +++ b/src/API/Response/Tracking/PickupTrackingResponse.php @@ -0,0 +1,164 @@ +entity; + } + + /** + * @param string $entity + */ + public function setEntity($entity): PickupTrackingResponse + { + $this->entity = $entity; + return $this; + } + + /** + * @return string + */ + public function getReference(): string + { + return $this->reference; + } + + /** + * @param string $reference + */ + public function setReference($reference): PickupTrackingResponse + { + $this->reference = $reference; + return $this; + } + + /** + * @return string + */ + public function getCollectionDate(): string + { + return $this->collectionDate; + } + + /** + * @param string $collectionDate + */ + public function setCollectionDate($collectionDate): PickupTrackingResponse + { + $this->collectionDate = $collectionDate; + return $this; + } + + /** + * @return string + */ + public function getPickupDate(): string + { + return $this->pickupDate; + } + + /** + * @param string $pickupDate + */ + public function setPickupDate($pickupDate): PickupTrackingResponse + { + $this->pickupDate = $pickupDate; + return $this; + } + + /** + * @return string + */ + public function getLastStatus(): string + { + return $this->lastStatus; + } + + /** + * @param string $lastStatus + */ + public function setLastStatus($lastStatus): PickupTrackingResponse + { + $this->lastStatus = $lastStatus; + return $this; + } + + /** + * @return string + */ + public function getLastStatusDescription(): string + { + return $this->lastStatusDescription; + } + + /** + * @param string $lastStatusDescription + */ + public function setLastStatusDescription($lastStatusDescription): PickupTrackingResponse + { + $this->lastStatusDescription = $lastStatusDescription; + return $this; + } + + /** + * @return string + */ + public function getCollectedWaybills(): string + { + return $this->collectedWaybills; + } + + /** + * @param string $collectedWaybills + */ + public function setCollectedWaybills($collectedWaybills): PickupTrackingResponse + { + $this->collectedWaybills = $collectedWaybills; + return $this; + } + + /** + * @param object $obj + * @return self + */ + protected function parse($obj) + { + parent::parse($obj); + + $this + ->setEntity($obj->Entity) + ->setReference($obj->Reference) + ->setCollectionDate($obj->CollectionDate) + ->setPickupDate($obj->PickupDate) + ->setLastStatus($obj->LastStatus) + ->setLastStatusDescription($obj->LastStatusDescription) + ->setCollectedWaybills($obj->CollectedWaybills); + + return $this; + } + + /** + * @param object $obj + * @return RateResponse + */ + public static function make($obj) + { + return (new self())->parse($obj); + } +} \ No newline at end of file diff --git a/src/API/Response/Tracking/ShipmentTrackingResponse.php b/src/API/Response/Tracking/ShipmentTrackingResponse.php new file mode 100644 index 0000000..7073209 --- /dev/null +++ b/src/API/Response/Tracking/ShipmentTrackingResponse.php @@ -0,0 +1,63 @@ +results; + } + + /** + * @param $results + * @return ShipmentTrackingResponse + */ + public function setResults($results): ShipmentTrackingResponse + { + $this->results = $results; + return $this; + } + + /** + * @param $result + * @return ShipmentTrackingResponse + */ + public function addResult(TrackingResult $result): ShipmentTrackingResponse + { + $this->results[] = $result; + return $this; + } + + /** + * @param object $obj + * @return self + */ + protected function parse($obj) + { + parent::parse($obj); + + if ($result = $obj->TrackingResults->KeyValueOfstringArrayOfTrackingResultmFAkxlpY) { + $this->addResult(TrackingResult::parse($result)); + } + + return $this; + } + + /** + * @param object $obj + * @return RateResponse + */ + public static function make($obj) + { + return (new self())->parse($obj); + } +} \ No newline at end of file diff --git a/src/Aramex.php b/src/Aramex.php new file mode 100644 index 0000000..6b2f3d6 --- /dev/null +++ b/src/Aramex.php @@ -0,0 +1,113 @@ +publishes([ + __DIR__ . '/../config/aramex.php' => config_path('aramex.php'), + ], 'ExtremeSa-aramex'); + + $this->publishes([ + __DIR__ . '/../resources/lang' => resource_path('lang/vendor/aramex'), + ], 'ExtremeSa-aramex'); + } + + public function register() + { + } +}