Skip to content

Commit d9a13af

Browse files
committed
Document usage of StarTrack, tidy up code
1 parent db3ad41 commit d9a13af

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Get a business account at Australia Post and request API access
1616

1717
```
1818
<?php
19-
$auspost = new \Cognito\Auspost\Auspost('Your API Key', 'Your API Password', 'Your Account Number', $testmode);
19+
$auspost = new \Cognito\Auspost\Auspost('Your API Key', 'Your API Password', 'Your Account Number', $testmode)
20+
->useStarTrack(); // only if using StarTrack
2021
2122
// Get your account details
2223
$account = $auspost->getAccountDetails();

src/Auspost.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class Auspost {
1515
private $api_key = null;
1616
private $api_password = null;
1717
private $account_number = null;
18+
private $raw_account = null;
1819
private $test_mode = null;
19-
private $star_track = null;
2020

2121
const API_SCHEME = 'tls://';
2222
const API_HOST = 'digitalapi.auspost.com.au';
@@ -35,20 +35,19 @@ class Auspost {
3535
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->raw_account = $account_number;
3839
$this->account_number = str_pad($account_number, 10, '0', STR_PAD_LEFT); // Ensure the account number is zero padded 10 digits
3940
$this->test_mode = $test_mode;
4041
}
41-
42+
4243
/**
4344
* Flags the Auspost instance as StarTrack
4445
*
45-
* @param string $account_number The StarTrack Account number
46-
* @return void
46+
* @return self
4747
*/
48-
public function starTrack($account_number)
49-
{
50-
$this->star_track = true;
51-
$this->account_number = $account_number;
48+
public function useStarTrack() {
49+
$this->account_number = $this->raw_account;
50+
return $this;
5251
}
5352

5453
/**

0 commit comments

Comments
 (0)