bluetools/moneybird_php_api — Issue #9: Don't get a MoneybirdAuthorizationRequiredException when using false login credentials
Author: uprise10
Created: 2012-01-16 11:36:43+00:00
State: open

When trying to login in the API with wrong user credentials I should expect the MoneybirdAuthorizationRequiredException, but this exception isn't throwed.

Instead of that it just continues to execute the following requests. Obviously these request will throw an error (for example a MoneybirdItemNotFoundException).. But these error isn't because of the item isn't there, but because the API cannot login due to wrong credentials.

It would be far better to just throw the MoneybirdAuthorizationRequiredException, so we can handle login actions on the right way.

This is the code that I used, so you can reproduce the error:

```php
$mbapi = null;
if( $subdomain != '' && $username != '' && $password != '') ) {
try {
$mbapi = new MoneybirdApi($subdomain, $username, $password);

$estimates = $mbapi->getContacts();
}
catch(MoneybirdAuthorizationRequiredException $e) {
echo "Authorization error:

";
var_dump($e);
echo "

";
}
catch(MoneybirdItemNotFoundException $e) {
echo "Not found error:

";
print_r($e);
echo "

";
}
}