Skip to content

Commit

Permalink
Add Facade
Browse files Browse the repository at this point in the history
Change make functions to run
  • Loading branch information
drashoor committed Nov 8, 2019
2 parents 6f728a0 + 6f5cfda commit 7f62ffa
Show file tree
Hide file tree
Showing 37 changed files with 427 additions and 232 deletions.
145 changes: 121 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,32 @@

Adds Aramex Functionality to Laravel.

This repo is a rebuild of digitalcloud/aramex.
This repo is a full rebuild of DigitalCloud/aramex.

## Table of Contents

* Installation
* QuickStart
* Location
* Rate
* Shipping
* Tracking
* [Installation](#installation)
* [QuickStart](#quickstart)
* [Location](#location)
* [Fetch Countries](#fetch-countries)
* [Fetch Country](#fetch-country)
* [Fetch States](#fetch-states)
* [Fetch Cities](#fetch-cities)
* [Validate Address](#validate-address)
* [Rate](#rate)
* [Calculate Rate](#calculate-rate)
* [Shipping](#shipping)
* [Create Pickup](#create-pickup)
* [Cancel Pickup](#cancel-Pickup)
* [Create Shipments](#create-shipments)
* [Get Last Shipments Numbers Range](#get-last-shipments-numbers-range)
* [Print Label](#print-label)
* [Reserve Shipment Number Range](#reserve-shipment-number-range)
* [Schedule Delivery](#schedule-delivery)
* [Tracking](#tracking)
* [Track Pickup](#track-pickup)
* [Track Shipments](#track-shipments)
* [Credits](#credits)

## Installation

Expand All @@ -24,68 +40,149 @@ Run the following command to install the latest applicable version of the packag
### Location

#### Fetch Countries
This method allows users to get the world countries list.

Aramex::FetchCountries()->make();
Aramex::fetchCountries()->run();

#### Fetch Country
This method allows users to get details of a certain country.

Aramex::FetchCountry()->make();
Aramex::fetchCountry()
->setCode('PS')
->run();

#### Fetch States
This method allows users to get all the states within a certain country (country code).

Aramex::FetchStates()->make();
Aramex::fetchStates()
->setCountryCode('AE')
->run();

#### Fetch Cities
This method allows users to get all the cities within a certain country (country code). And allows users to get list of the cities that start with a specific prefix. The required nodes to be filled are Client Info and Country Code.

Aramex::FetchCities()->make();
Aramex::fetchCities()
->setCountryCode('AE')
->run();

#### Validate Address

Aramex::ValidateAddress()->make();
This method Allows users to search for certain addresses and make sure that the address structure is correct.

Aramex::validateAddress()
->setAddress(
(new Address()) ...
)->run();

### Rate

### Calculate Rate
#### Calculate Rate
This method allows users to get rate for source/destinations shipment.

$source = (new Address()) ... ;

$destination = (new Address()) ...;

Aramex::CalculateRate()->make();
$details = (new ShipmentDetails()) ...;

Aramex::calculateRate()
->setOriginalAddress($source)
->setDestinationAddress($destination)
->setShipmentDetails($details)
->setPreferredCurrencyCode('USD')
->run();

### Shipping

#### Create Pickup
This method allows users to create a pickup request.

Aramex::CreatePickup()->make();
$source = (new Address());

$contact = (new Contact());
$pickupItem = (new PickupItem());

$pickup = (new Pickup())
->setPickupAddress($source)
->setPickupContact($contact)
->setPickupLocation('Reception')
->setPickupDate(Carbon::now()->timestamp)
->setReadyTime(Carbon::now()->timestamp)
->setLastPickupTime(Carbon::now()->addDay()->timestamp)
->setClosingTime(Carbon::now()->addDay()->timestamp)
->setStatus('Pending')
->setReference1('')
->addPickupItem($pickupItem);
$labelInfo = (new LabelInfo())
->setReportId(9201)
->setReportType('URL');
Aramex::createPickup()
->setLabelInfo($labelInfo)
->setPickup($pickup)
->run();

#### Cancel Pickup
This method allows you to cancel a pickup as long as it is un-assigned or pending details.

Aramex::CancelPickup()->make();
Aramex::cancelPickup()
->setPickupGUID('PICKUP_GUID')
->run();

#### Create Shipments
This method allows users to create shipments on Aramex’s system.

Aramex::CreateShipments()->make();
Aramex::createShipments()->run();

#### Get Last Shipments Numbers Range
This method allows you to inquire about the last reserved range using a specific entity and product group

Aramex::GetLastShipmentsNumbersRange()->make();
Aramex::getLastShipmentsNumbersRange()
->setEntity('ENTITY')
->setProductGroup('PRODUCT_GROUP')
->run();

#### Print Label
This method allows the user to print a label for an existing shipment.

Aramex::PrintLabel()->make();
$labelInfo = (new \ExtremeSa\Aramex\API\Classes\LabelInfo())
->setReportId(9201)
->setReportType('URL');
Aramex::printLabel()
->setShipmentNumber('SHIPMENT_NO')
->setLabelInfo()
->run();

#### Reserve Shipment Number Range
This method allows you to reserve a range of shipment numbers.

Aramex::ReserveShipmentNumberRange()->make();
Aramex::reserveShipmentNumberRange()->run();

#### Schedule Delivery
This method allows you to schedule the delivery of a shipment at a specified time and place (Longitude and Latitude)

Aramex::ScheduleDelivery()->make();
Aramex::scheduleDelivery()->run();

### Tracking

#### Track Pickup
This method allows the user to track an existing pickup’s updates and latest status.

Aramex::TrackPickup()->make();
Aramex::trackPickup()
->setReference('PICKUP_NO')
->setPickup('PICKUP') // any number
->run();

#### Track Shipments
This method allows the user to track an existing shipment’s updates and latest status.

Aramex::TrackShipments()->make();
Aramex::trackShipments()
->setShipments(['SHIPMENT_NO'])
->run();
## Credits

* [Ismail Ashour](https://github.com/drashoor/)
* All Contributors
7 changes: 7 additions & 0 deletions src/API/Classes/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function getCode(): ?string

/**
* @param string|null $code
* @return Country
*/
public function setCode(string $code): Country
{
Expand All @@ -48,6 +49,7 @@ public function getName(): ?string

/**
* @param string|null $name
* @return Country
*/
public function setName(string $name): Country
{
Expand All @@ -65,6 +67,7 @@ public function getIsoCode(): ?string

/**
* @param string|null $isoCode
* @return Country
*/
public function setIsoCode(string $isoCode): Country
{
Expand All @@ -82,6 +85,7 @@ public function getStateRequired(): bool

/**
* @param bool $stateRequired
* @return Country
*/
public function setStateRequired(bool $stateRequired): Country
{
Expand All @@ -99,6 +103,7 @@ public function getPostCodeRequired(): bool

/**
* @param bool $postCodeRequired
* @return Country
*/
public function setPostCodeRequired(bool $postCodeRequired): Country
{
Expand All @@ -117,6 +122,7 @@ public function getPostCodeRegex(): ?array
/**
* @param array $postCodeRegex
* todo
* @return Country
*/
public function setPostCodeRegex(array $postCodeRegex): Country
{
Expand All @@ -134,6 +140,7 @@ public function getInternationalCallingNumber(): ?string

/**
* @param string|null $internationalCallingNumber
* @return Country
*/
public function setInternationalCallingNumber(string $internationalCallingNumber): Country
{
Expand Down
8 changes: 6 additions & 2 deletions src/API/Classes/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ public function getShippingDate()
/**
* The date Aramex receives the shipment to be shipped out.
* @param mixed $shippingDate
* @return DateTime
*/
public function setShippingDate($shippingDate): void
public function setShippingDate($shippingDate): DateTime
{
$this->shippingDate = $shippingDate;
return $this;
}

/**
Expand All @@ -38,10 +40,12 @@ public function getDueDate()
/**
* The date specified for shipment to be delivered to the consignee.
* @param mixed $dueDate
* @return DateTime
*/
public function setDueDate($dueDate): void
public function setDueDate($dueDate): DateTime
{
$this->dueDate = $dueDate;
return $this;
}


Expand Down
30 changes: 16 additions & 14 deletions src/API/Classes/Dimension.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public function getLength()
/**
* 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
* @return Dimension
*/
public function setLength(float $length)
public function setLength(float $length): Dimension
{
$this->length = $length;
return $this;
Expand All @@ -48,9 +48,9 @@ public function getWidth()
/**
* 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
* @return Dimension
*/
public function setWidth(float $width)
public function setWidth(float $width): Dimension
{
$this->width = $width;
return $this;
Expand All @@ -67,9 +67,9 @@ public function getHeight()
/**
* 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
* @return Dimension
*/
public function setHeight(float $height)
public function setHeight(float $height): Dimension
{
$this->height = $height;
return $this;
Expand All @@ -88,30 +88,32 @@ public function getUnit()
* CM = Centimeter
* M = Meter
* @param string $unit
* @return $this
* @return Dimension
*/
public function setUnit(string $unit)
public function setUnit(string $unit): Dimension
{
$this->unit = $unit;
return $this;
}

/**
* Centimeter
* @return $this
* @return Dimension
*/
public function useCentimeterAsUnit()
public function useCentimeterAsUnit(): Dimension
{
return $this->setUnit('CM');
$this->setUnit('CM');
return $this;
}

/**
* Meter
* @return $this
* @return Dimension
*/
public function useMeterAsUnit()
public function useMeterAsUnit(): Dimension
{
return $this->setUnit('M');
$this->setUnit('M');
return $this;
}

public function normalize(): array
Expand Down
4 changes: 2 additions & 2 deletions src/API/Classes/LabelInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function getReportId(): int
* @param int $reportId
* @return $this
*/
public function setReportId(int $reportId)
public function setReportId(int $reportId): LabelInfo
{
$this->reportId = $reportId;
return $this;
Expand All @@ -49,7 +49,7 @@ public function getReportType(): string
* @param string $reportType : URL|RPT
* @return $this
*/
public function setReportType(string $reportType)
public function setReportType(string $reportType): LabelInfo
{
$this->reportType = $reportType;
return $this;
Expand Down
Loading

0 comments on commit 7f62ffa

Please sign in to comment.