Skip to content

Commit

Permalink
Add getBalance() method (#2)
Browse files Browse the repository at this point in the history
* Add getBalance method
Minor fixes
  • Loading branch information
dadditsdonovskiy committed Feb 17, 2020
1 parent e0f62ec commit e4ec8e4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/api/Envelope.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,15 +420,21 @@ public function getShowPrice()
* @return bool
*/
public function checkBalance()
{
return $this->getBalance() >= 3;
}

/**
* @return float
*/
public function getBalance()
{
$accountInfoResponse = $this->soapClient->GetAccountInfo([
'Authenticator' => $this->getAuthToken(),
]);
$this->setAuthToken($accountInfoResponse->Authenticator);

$availableBalance = (double)$accountInfoResponse->AccountInfo->PostageBalance->AvailablePostage;

return $availableBalance >= 3;
return (double)$accountInfoResponse->AccountInfo->PostageBalance->AvailablePostage;
}

/**
Expand Down
10 changes: 10 additions & 0 deletions src/api/EnvelopeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,14 @@ public function setShowPrice($flag);
* @return bool
*/
public function getShowPrice();

/**
* @return bool
*/
public function checkBalance();

/**
* @return float
*/
public function getBalance();
}

0 comments on commit e4ec8e4

Please sign in to comment.