Skip to content

Commit

Permalink
Merge pull request #13 from aubryfr/hotfix/verify_AttachableResponse_…
Browse files Browse the repository at this point in the history
…structure

Verying the QuickBooks Attachable response against the expected structure
  • Loading branch information
aubryfr authored Apr 14, 2017
2 parents d615e34 + 94ea978 commit 012987c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/DataService.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,16 @@ public function upload($fileName, $contentType, $content)
];
$response = $this->request('POST', $this->getRequestUrl('upload'), $body, $headers);

if (!isset($response['AttachableResponse'])) {
throw new \UnexpectedValueException('The QuickBooks response should contain an "AttachableResponse" node');
}

$response = reset($response['AttachableResponse']);

if (false === $response) {
throw new \UnexpectedValueException('The QuickBooks AttachableResponse is empty');
}

if (isset($response['Fault'])) {
throw $this->createFaultException($response);
}
Expand Down

0 comments on commit 012987c

Please sign in to comment.