Skip to content

Commit 44aa0fe

Browse files
Make startrack integration backward compatible
1 parent ec2356e commit 44aa0fe

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/Auspost.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,24 @@ class Auspost {
3232
* @param string $account_number The AusPost Account number
3333
* @param bool $test_mode Whether to use test mode or not
3434
*/
35-
public function __construct($api_key, $api_password, $account_number, $star_track = false, $test_mode = false) {
35+
public function __construct($api_key, $api_password, $account_number, $test_mode = false) {
3636
$this->api_key = $api_key;
3737
$this->api_password = $api_password;
38-
$this->star_track = $star_track;
39-
$this->account_number = !$star_track ? str_pad($account_number, 10, '0', STR_PAD_LEFT) : $account_number; // Ensure the account number is zero padded 10 digits
38+
$this->account_number = str_pad($account_number, 10, '0', STR_PAD_LEFT); // Ensure the account number is zero padded 10 digits
4039
$this->test_mode = $test_mode;
4140
}
41+
42+
/**
43+
* Flags the Auspost instance as StarTrack
44+
*
45+
* @param string $account_number The StarTrack Account number
46+
* @return void
47+
*/
48+
public function starTrack($account_number)
49+
{
50+
$this->star_track = true;
51+
$this->account_number = $account_number;
52+
}
4253

4354
/**
4455
* Perform a GetAccounts API call.

0 commit comments

Comments
 (0)