Skip to content

Commit

Permalink
update shipment options and documentation
Browse files Browse the repository at this point in the history
* add references
* update decumentation references
* sync error responses in create shipment
  • Loading branch information
Moustafa22 committed Jan 17, 2021
1 parent a62d60d commit 66187ba
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 23 deletions.
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,25 @@ composer require octw/aramex
'due_date' => time() + 60000, // due date of the shipment
'comments' => 'No Comment', // ,comments
'pickup_location' => 'at reception', // location as pickup
'pickup_guid' => $guid, // GUID taken from createPickup method
'pickup_guid' => $guid, // GUID taken from createPickup method (optional)
'weight' => 1, // weight
'number_of_pieces' => 1, // number of boxes
'goods_country' => null, // optional
'number_of_pieces' => 1, // number of items
'description' => 'Goods Description, like Boxes of flowers', // description
'reference' => '01020102' // reference to print on shipment report (policy)
'shipper_reference' => '19191', // optional
'consignee_reference' => '010101', // optional
'services' => 'CODS,FIRST,FRDM, .. ' // ',' seperated string, refer to services in the official documentation
'cash_on_delivery_amount' => 10.32 // in case of CODS (in USD only "as they want")
'insurance_amount' => 0, // optional
'collect_amount' => 0, // optional
'customs_value_amount' => 0, //optional (required for express shipping)
'cash_additional_amount' => 0, // optional
'cash_additional_amount_description' => 'Something here',
'product_group' => 'DOM', // or EXP (defined in config file, if you dont pass it will take the config value)
'product_type' => 'PPX', // refer to the official documentation (defined in config file, if you dont pass it will take the config value)
'payment_type' => 'P', // P,C, 3 refer to the official documentation (defined in config file, if you dont pass it will take the config value)
'payment_option' => null, // refer to the official documentation (defined in config file, if you dont pass it will take the config value)
```

retrun stdClass:
Expand Down Expand Up @@ -286,7 +301,7 @@ composer require octw/aramex
'due_date' => time() + 60000,
'comments' => 'No Comment',
'pickup_location' => 'at reception',
'pickup_guid' => $guid,
// 'pickup_guid' => $guid,
'weight' => 1,
'number_of_pieces' => 1,
'description' => 'Goods Description, like Boxes of flowers',
Expand Down
5 changes: 5 additions & 0 deletions src/Aramex.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ public static function createShipment($param =[])

if ($call->HasErrors) {
$ret->error = 1;
if (isset($call->Notifications->Notification))
{
$ret->errors = [$call->Notifications->Notification];
}

if (is_object($call->Shipments->ProcessedShipment->Notifications->Notification))
{
$ret->errors = [ $call->Shipments->ProcessedShipment->Notifications->Notification ];
Expand Down
34 changes: 18 additions & 16 deletions src/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ public function __construct()
public function initializeShipment($shipper , $consignee , $details)
{
$this->param['Shipments'] = [
'Shipment' => [
[
'Shipper' => [
'Reference1' => $details->ShipperReference, // for response
'AccountNumber' => $this->accNum,
'Contact' => [
'PersonName' => $shipper->PersonName,
Expand All @@ -95,8 +96,7 @@ public function initializeShipment($shipper , $consignee , $details)
],
],
'Consignee' => [
'Reference1' => time(), // for response
'Reference2' => '', // for response
'Reference1' => $details->ConsgineeReference, // for response
'AccountNumber' => $this->accNum, //Account Number
'Contact' => [
'PersonName' => $consignee->PersonName,//Person Name
Expand All @@ -114,17 +114,17 @@ public function initializeShipment($shipper , $consignee , $details)
],

],

'ShippingDateTime' => $details->ShippingDateTime, // Should be Filled
"DueDate"=> $details->DueDate, // Should be Filled
"Comments"=> $details->Comments, //Should Be Filled
"PickupLocation"=> $details->PickupLocation, // Should be Filled
"Attachments"=> null,
"ForeignHAWB"=> null,
"TransportType"=> "0",
"PickupGUID"=> $details->PickupGUID,
"Number"=> null,
'Details' => [
'ShippingDateTime' => $details->ShippingDateTime, // Should be Filled
"DueDate" => $details->DueDate, // Should be Filled
"Comments" => $details->Comments, //Should Be Filled
"PickupLocation" => $details->PickupLocation, // Should be Filled
"Attachments" => null,
"ForeignHAWB" => null,
'Reference1' => $details->Reference1, // for response
"TransportType" => 0,
"PickupGUID" => $details->PickupGUID,
"Number" => null,
'Details' => [
'ActualWeight' => [
'Value' => $details->ActualWeight,
'Unit' => 'Kg'
Expand All @@ -138,6 +138,7 @@ public function initializeShipment($shipper , $consignee , $details)
'DescriptionOfGoods' => $details->DescriptionOfGoods,
'GoodsOriginCountry' => $details->GoodsOriginCountry,
'Services' => $details->Services,
'Items' => $details->NumberOfPieces,

// Optionals Depending on Payment terms above

Expand All @@ -148,7 +149,8 @@ public function initializeShipment($shipper , $consignee , $details)

'CashOnDeliveryAmount' => [
'Value' => $details->CashOnDeliveryAmount,
'CurrencyCode' => $details->CurrencyCode
'CurrencyCode' => 'USD'
// 'CurrencyCode' => $details->CurrencyCode
],

'InsuranceAmount' => [
Expand All @@ -168,7 +170,7 @@ public function initializeShipment($shipper , $consignee , $details)
],

]
]
]
];

}
Expand Down
7 changes: 5 additions & 2 deletions src/Helpers/AramexHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,13 @@ public static function extractShipmentDetails($param = []){

$shipmentDetails->ProductGroup = $param['product_group'] ?? config('aramex.ProductGroup');
$shipmentDetails->ProductType = $param['product_type'] ?? config('aramex.ProductType');
$shipmentDetails->PaymentType = $param['payment_type'] ?? config('aramex.Payment');
$shipmentDetails->PaymentType = $param['payment_type'] ?? config('aramex.Payment');
$shipmentDetails->PaymentOptions = $param['payment_options'] ?? config('aramex.PaymentOptions');
$shipmentDetails->PaymentOptions = $param['payment_option'] ?? config('aramex.PaymentOptions');
$shipmentDetails->Services = $param['services'] ?? config('aramex.Services');
$shipmentDetails->Reference1 = $param['reference'] ?? '';
$shipmentDetails->ShipperReference = $param['shipper_reference'] ?? '';
$shipmentDetails->ConsgineeReference = $param['consignee_reference'] ?? '';


$shipmentDetails->DescriptionOfGoods = $param['description'] ?? "";

Expand Down
1 change: 0 additions & 1 deletion src/Validators/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public static function validateShipmentDetails($param)
'shipping_date_time' => 'required',
'due_date' => 'required',
'pickup_location' => 'required',
'pickup_guid' => 'required',
'weight' => 'required',
]);
if ($validator->fails())
Expand Down
2 changes: 1 addition & 1 deletion src/config/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
/**
* Label Information
* Available Values:
* ReportID => 9201 only (No one knows why do we send it if its only can be set to 9201 !!)
* ReportID => 9201, 9729 (9729 use it when COD to extract readable reports, 9201 with COD will not be accepted)
* ReportType => “URL” to get report hosted on URL as PDF
* “RPT” to get a streamed file
*/
Expand Down

0 comments on commit 66187ba

Please sign in to comment.