Skip to content

Commit

Permalink
Finish 0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Ismail Ashour committed Nov 8, 2019
2 parents 167c631 + ce81912 commit 966a241
Show file tree
Hide file tree
Showing 33 changed files with 149 additions and 192 deletions.
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{
"name": "extremesa/aramex",
"description": "",
"description": "Integrate Laravel project with Aramex.",
"keywords": [
],
"authors": [
{
"name": "Ismail Ashour",
"email": "iashour@extreme.sa"
}
],
"license": "MIT",
"require": {
"php": ">=7.1.0",
Expand Down
9 changes: 9 additions & 0 deletions src/API/Classes/Office.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function getEntity(): string

/**
* @param string $entity
* @return Office
*/
public function setEntity(string $entity): Office
{
Expand All @@ -50,6 +51,7 @@ public function getEntityDescription(): string

/**
* @param string $entityDescription
* @return Office
*/
public function setEntityDescription(string $entityDescription): Office
{
Expand All @@ -67,6 +69,7 @@ public function getOfficeType(): string

/**
* @param string $officeType
* @return Office
*/
public function setOfficeType(string $officeType): Office
{
Expand All @@ -84,6 +87,7 @@ public function getAddress(): Address

/**
* @param Address $address
* @return Office
*/
public function setAddress(Address $address): Office
{
Expand All @@ -101,6 +105,7 @@ public function getTelephone(): ?string

/**
* @param string|null $telephone
* @return Office
*/
public function setTelephone(?string $telephone): Office
{
Expand All @@ -118,6 +123,7 @@ public function getWorkingDays(): string

/**
* @param string $workingDays
* @return Office
*/
public function setWorkingDays(string $workingDays): Office
{
Expand All @@ -135,6 +141,7 @@ public function getWorkingHours(): string

/**
* @param string $workingHours
* @return Office
*/
public function setWorkingHours(string $workingHours): Office
{
Expand All @@ -152,6 +159,7 @@ public function getLongtitude(): ?float

/**
* @param mixed $longtitude
* @return Office
*/
public function setLongtitude(float $longtitude): Office
{
Expand All @@ -169,6 +177,7 @@ public function getLatitude(): ?float

/**
* @param float $latitude
* @return Office
*/
public function setLatitude(float $latitude): Office
{
Expand Down
3 changes: 1 addition & 2 deletions src/API/Classes/TrackingResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,12 @@ public function setWeightUnit(string $weightUnit): TrackingResult

/**
* @param object $obj
* @return Track
* @return TrackingResult
*/
public static function parse($obj)
{
$obj = $obj->Value->TrackingResult;


return (new self())
->setWaybillNumber($obj->WaybillNumber)
->setUpdateCode($obj->UpdateCode)
Expand Down
10 changes: 8 additions & 2 deletions src/API/Requests/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ abstract class API implements Normalize
protected $live_wsdl;
protected $environment;

public function __construct()
public function __construct($environment = null)
{
config('aramex.mode') === 'live' ? $this->useLiveAsEnvironment() : $this->useTestAsEnvironment();
if ($environment) {
$this->setEnvironment($environment);
} else {
config('aramex.mode') === 'live' ? $this->useLiveAsEnvironment() : $this->useTestAsEnvironment();
}

dd($this->environment);

$this->fillClientInfoFromEnv();

Expand Down
4 changes: 4 additions & 0 deletions src/API/Requests/Location/FetchCities.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class FetchCities extends API implements Normalize

/**
* @return CitiesFetchingResponse
* @throws \Exception
*/
public function fetch()
{
Expand All @@ -43,6 +44,7 @@ public function getCountryCode(): ?string

/**
* @param string $countryCode
* @return FetchCities
*/
public function setCountryCode(string $countryCode): FetchCities
{
Expand All @@ -60,6 +62,7 @@ public function getState(): ?string

/**
* @param string|null $state
* @return FetchCities
*/
public function setState(?string $state): FetchCities
{
Expand All @@ -77,6 +80,7 @@ public function getNameStartsWith(): ?string

/**
* @param string|null $nameStartsWith
* @return FetchCities
*/
public function setNameStartsWith(?string $nameStartsWith): FetchCities
{
Expand Down
1 change: 1 addition & 0 deletions src/API/Requests/Location/FetchCountries.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class FetchCountries extends API implements Normalize

/**
* @return CountriesFetchingResponse
* @throws \Exception
*/
public function fetch()
{
Expand Down
4 changes: 3 additions & 1 deletion src/API/Requests/Location/FetchCountry.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace ExtremeSa\Aramex\API\Requests\Location;

use Exception;
use ExtremeSa\Aramex\API\Interfaces\Normalize;
use ExtremeSa\Aramex\API\Requests\API;
use ExtremeSa\Aramex\API\Response\Location\CountryFetchingResponse;
use Exception;

class FetchCountry extends API implements Normalize
{
Expand All @@ -16,6 +16,7 @@ class FetchCountry extends API implements Normalize

/**
* @return CountryFetchingResponse
* @throws Exception
*/
public function fetch()
{
Expand Down Expand Up @@ -43,6 +44,7 @@ public function getCode(): string

/**
* @param string $code
* @return FetchCountry
*/
public function setCode(string $code): FetchCountry
{
Expand Down
4 changes: 3 additions & 1 deletion src/API/Requests/Location/FetchOffices.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace ExtremeSa\Aramex\API\Requests\Location;

use Exception;
use ExtremeSa\Aramex\API\Interfaces\Normalize;
use ExtremeSa\Aramex\API\Requests\API;
use ExtremeSa\Aramex\API\Response\Location\OfficesFetchingResponse;
use Exception;

/**
* This method allows users to get list of the available ARAMEX offices within a certain country.
Expand All @@ -23,6 +23,7 @@ class FetchOffices extends API implements Normalize

/**
* @return OfficesFetchingResponse
* @throws Exception
*/
public function fetch()
{
Expand Down Expand Up @@ -50,6 +51,7 @@ public function getCountryCode(): string

/**
* @param string $countryCode
* @return FetchOffices
*/
public function setCountryCode(string $countryCode): FetchOffices
{
Expand Down
4 changes: 3 additions & 1 deletion src/API/Requests/Location/FetchStates.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace ExtremeSa\Aramex\API\Requests\Location;

use Exception;
use ExtremeSa\Aramex\API\Interfaces\Normalize;
use ExtremeSa\Aramex\API\Requests\API;
use ExtremeSa\Aramex\API\Response\Location\StatesFetchingResponse;
use Exception;

class FetchStates extends API implements Normalize
{
Expand All @@ -16,6 +16,7 @@ class FetchStates extends API implements Normalize

/**
* @return StatesFetchingResponse
* @throws Exception
*/
public function fetch()
{
Expand Down Expand Up @@ -43,6 +44,7 @@ public function getCountryCode(): string

/**
* @param string $countryCode
* @return FetchStates
*/
public function setCountryCode(string $countryCode): FetchStates
{
Expand Down
5 changes: 3 additions & 2 deletions src/API/Requests/Location/ValidateAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class ValidateAddress extends API implements Normalize
private $address;

/**
* @return ValidateAddress
* @return AddressValidationResponse
* @throws \Exception
*/
public function check()
{
$this->validate();

dd($this->soapClient->ValidateAddress($this->normalize()));
return AddressValidationResponse::make($this->soapClient->ValidateAddress($this->normalize()));
}

Expand All @@ -52,6 +52,7 @@ public function getAddress(): Address

/**
* @param Address $address
* @return ValidateAddress
*/
public function setAddress(Address $address): ValidateAddress
{
Expand Down
15 changes: 11 additions & 4 deletions src/API/Requests/Rate/CalculateRate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace ExtremeSa\Aramex\API\Requests\Rate;

use Exception;
use ExtremeSa\Aramex\API\Classes\Address;
use ExtremeSa\Aramex\API\Classes\ShipmentDetails;
use ExtremeSa\Aramex\API\Interfaces\Normalize;
Expand All @@ -19,8 +20,14 @@ class CalculateRate extends API implements Normalize
protected $live_wsdl = 'https://ws.aramex.net/ShippingAPI.V2/RateCalculator/Service_1_0.svc?wsdl';
protected $test_wsdl = 'https://ws.aramex.net/ShippingAPI.V2/RateCalculator/Service_1_0.svc?wsdl';

public function __construct()
{
parent::__construct('live');
}

/**
* @return RateResponse
* @return RateCalculatorResponse
* @throws Exception
*/
public function calculate()
{
Expand All @@ -34,15 +41,15 @@ protected function validate()
Parent::validate();

if (!$this->originalAddress) {
throw new \Exception('Origin Address not provided');
throw new Exception('Origin Address not provided');
}

if (!$this->destinationAddress) {
throw new \Exception('Destination Address not provided');
throw new Exception('Destination Address not provided');
}

if (!$this->shipmentDetails) {
throw new \Exception('Shipment Details not provided');
throw new Exception('Shipment Details not provided');
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/API/Requests/Shipping/CancelPickup.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace ExtremeSa\Aramex\API\Requests\Shipping;

use Exception;
use ExtremeSa\Aramex\API\Interfaces\Normalize;
use ExtremeSa\Aramex\API\Requests\API;
use ExtremeSa\Aramex\API\Response\Shipping\PickupCancellationResponse;
use Exception;

/**
* This method allows you to cancel a pickup as long as it is un-assigned or pending details.
Expand Down
10 changes: 5 additions & 5 deletions src/API/Requests/Shipping/CreatePickup.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace ExtremeSa\Aramex\API\Requests\Shipping;

use Exception;
use ExtremeSa\Aramex\API\Classes\LabelInfo;
use ExtremeSa\Aramex\API\Classes\Pickup;
use ExtremeSa\Aramex\API\Interfaces\Normalize;
use ExtremeSa\Aramex\API\Requests\API;
use ExtremeSa\Aramex\API\Response\Shipping\PickupCreationResponse;
use Exception;

/**
* This method allows users to create a pickup request.
Expand Down Expand Up @@ -45,9 +45,9 @@ public function getPickup()

/**
* @param Pickup $pickup
* @return $this
* @return CreatePickup
*/
public function setPickup(Pickup $pickup)
public function setPickup(Pickup $pickup): CreatePickup
{
$this->pickup = $pickup;
return $this;
Expand All @@ -63,9 +63,9 @@ public function getLabelInfo()

/**
* @param LabelInfo $labelInfo
* @return $this
* @return CreatePickup
*/
public function setLabelInfo(LabelInfo $labelInfo)
public function setLabelInfo(LabelInfo $labelInfo): CreatePickup
{
$this->labelInfo = $labelInfo;
return $this;
Expand Down
Loading

0 comments on commit 966a241

Please sign in to comment.