diff --git a/UnitTestFiles/Test/OrderTests.php b/UnitTestFiles/Test/OrderTests.php index 178508a..bebae13 100644 --- a/UnitTestFiles/Test/OrderTests.php +++ b/UnitTestFiles/Test/OrderTests.php @@ -111,6 +111,7 @@ public function testFromArray() 'name' => 'Bill Soul', ], ], + 'EXT_FIELD_cost' => 50 ]); $this->assertEquals('1358 E Luzerne St, Philadelphia, PA 19124, US', $orderParameters->address_1); @@ -129,6 +130,7 @@ public function testFromArray() 'name' => 'Bill Soul', ], ], $orderParameters->EXT_FIELD_custom_data); + $this->assertEquals(50, $orderParameters->EXT_FIELD_cost); } public function testToArray() @@ -152,21 +154,24 @@ public function testToArray() ], ]); - $this->assertEquals($orderParameters->toArray(), [ - 'address_1' => '1358 E Luzerne St, Philadelphia, PA 19124, US', - 'cached_lat' => 48.335991, - 'cached_lng' => 31.18287, - 'address_alias' => 'Auto test address', - 'address_city' => 'Philadelphia', - 'day_scheduled_for_YYMMDD' => date('Y-m-d'), - 'EXT_FIELD_first_name' => 'Igor', - 'EXT_FIELD_last_name' => 'Progman', - 'EXT_FIELD_email' => 'progman@gmail.com', - 'EXT_FIELD_phone' => '380380380380', - 'EXT_FIELD_custom_data' => [ - 0 => [ - 'order_id' => '10', - 'name' => 'Bill Soul', + $this->assertEquals( + $orderParameters->toArray(), + [ + 'address_1' => '1358 E Luzerne St, Philadelphia, PA 19124, US', + 'cached_lat' => 48.335991, + 'cached_lng' => 31.18287, + 'address_alias' => 'Auto test address', + 'address_city' => 'Philadelphia', + 'day_scheduled_for_YYMMDD' => date('Y-m-d'), + 'EXT_FIELD_first_name' => 'Igor', + 'EXT_FIELD_last_name' => 'Progman', + 'EXT_FIELD_email' => 'progman@gmail.com', + 'EXT_FIELD_phone' => '380380380380', + 'EXT_FIELD_custom_data' => [ + 0 => [ + 'order_id' => '10', + 'name' => 'Bill Soul', + ], ], ], ]); @@ -502,7 +507,9 @@ public function testUpdateOrder() $this->assertEquals('Lviv', $response['address_2']); $this->assertEquals('032268593', $response['EXT_FIELD_phone']); $this->assertEquals( - [0 => '{"order_id":"10","name":"Bill Soul"}'], + [ + 0 => '{"order_id":"10","name":"Bill Soul"}' + ], $response['EXT_FIELD_custom_data'] ); } diff --git a/composer.json b/composer.json index 49fc87d..6aeed78 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "route4me/route4me-php", "description": "Access Route4Me's logistics-as-a-service API using our PHP SDK", "minimum-stability": "stable", - "version": "1.3.0", + "version": "1.3.1", "authors": [ { "name": "Igor Route4Me", diff --git a/examples/Order/NewOrderWithEXTFields.php b/examples/Order/NewOrderWithEXTFields.php new file mode 100644 index 0000000..65bdbb2 --- /dev/null +++ b/examples/Order/NewOrderWithEXTFields.php @@ -0,0 +1,36 @@ + '1358 E Luzerne St, Philadelphia, PA 19124, US', + 'cached_lat' => 48.335991, + 'cached_lng' => 31.18287, + 'address_alias' => 'Auto test address', + 'address_city' => 'Philadelphia', + 'day_scheduled_for_YYMMDD' => date('Y-m-d'), + 'EXT_FIELD_first_name' => 'Igor', + 'EXT_FIELD_last_name' => 'Progman', + 'EXT_FIELD_email' => 'progman@gmail.com', + 'EXT_FIELD_phone' => '380380380380', + 'EXT_FIELD_weight' => 100.0, + 'EXT_FIELD_cost' => 50, + 'EXT_FIELD_revenue' => 150, + 'EXT_FIELD_cube' => 5, + 'EXT_FIELD_pieces' => 10 +]); + +$order = new Order(); + +$response = $order->addOrder($orderParameters); + +Route4Me::simplePrint($response); diff --git a/src/Route4Me/Order.php b/src/Route4Me/Order.php index 7f31ba0..a48bce0 100644 --- a/src/Route4Me/Order.php +++ b/src/Route4Me/Order.php @@ -63,6 +63,36 @@ class Order extends Common public $addresses = []; + /** + * Weight of the order. + * @since 1.2.11 + */ + public $EXT_FIELD_weight; + + /** + * Cost of the order. + * @since 1.2.11 + */ + public $EXT_FIELD_cost; + + /** + * The total revenue for the order. + * @since 1.2.11 + */ + public $EXT_FIELD_revenue; + + /** + * The cubic volume of the cargo. + * @since 1.2.11 + */ + public $EXT_FIELD_cube; + + /** + *The item quantity of the cargo. + * @since 1.2.11 + */ + public $EXT_FIELD_pieces; + public function __construct() { Route4Me::setBaseUrl(Endpoint::BASE_URL);