-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from route4me/order_v4_add_fields
Added EXT_FIELDs to class Order V4.
- Loading branch information
Showing
4 changed files
with
90 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' => '[email protected]', | ||
'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' => '[email protected]', | ||
'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'] | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Route4Me; | ||
|
||
$root = realpath(dirname(__FILE__).'/../../'); | ||
require $root.'/vendor/autoload.php'; | ||
|
||
// Example refers to creating a new Order. | ||
|
||
// Set the api key in the Route4me class | ||
// This example not available for demo API key | ||
Route4Me::setApiKey(Constants::API_KEY); | ||
|
||
$orderParameters = Order::fromArray([ | ||
'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' => '[email protected]', | ||
'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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters