File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed
Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,9 @@ Get a business account at Australia Post and request API access
2525
2626 $shipment = $auspost->newShipment()
2727 ->setFrom(new \Cognito\Auspost\Address([
28- 'name' => 'Joe Tester',
28+ 'first_name' => 'Joe',
29+ 'last_name' => 'Tester',
30+ // OR 'name' => 'Joe Tester',
2931 'lines' => [
3032 '11 MyStreetname Court',
3133 ],
@@ -35,7 +37,8 @@ Get a business account at Australia Post and request API access
3537 'country' => 'AU',
3638 ]))
3739 ->setTo(new \Cognito\Auspost\Address([
38- 'name' => 'Mary Tester',
40+ 'first_name' => 'Mary',
41+ 'last_name' => 'Tester',
3942 'lines' => [
4043 '10 ReceiverStreetname St',
4144 ],
Original file line number Diff line number Diff line change 99 * @author Josh Marshall <josh@jmarshall.com.au>
1010 *
1111 * @property string $type
12+ * @property string $first_name
13+ * @property string $last_name
1214 * @property string $name
1315 * @property string $business_name
1416 * @property string[] $lines
2224class Address {
2325
2426 public $ type = '' ;
27+ public $ first_name = '' ;
28+ public $ last_name = '' ;
2529 public $ name = '' ;
2630 public $ business_name = '' ;
2731 public $ lines = [];
@@ -41,5 +45,18 @@ public function __construct($details = []) {
4145 }
4246 $ this ->$ key = $ data ;
4347 }
48+ if (!$ this ->name ) {
49+ $ this ->name = trim ($ this ->first_name . ' ' . $ this ->last_name );
50+ }
51+ if (!$ this ->first_name ) {
52+ $ parts = explode (' ' , $ this ->name , 2 );
53+ if (count ($ parts ) > 1 ) {
54+ $ this ->first_name = $ parts [0 ];
55+ $ this ->last_name = $ parts [1 ];
56+ } else {
57+ $ this ->first_name = $ this ->name ;
58+ $ this ->last_name = $ this ->name ;
59+ }
60+ }
4461 }
4562}
Original file line number Diff line number Diff line change @@ -470,7 +470,7 @@ private function closeSocket() {
470470 /**
471471 * Convert the lines of response data into an associative array.
472472 *
473- * @param array $data lines of response data
473+ * @param string $data lines of response data
474474 * @return array associative array
475475 */
476476 private function convertResponse ($ data ) {
You can’t perform that action at this time.
0 commit comments