Skip to content

Commit

Permalink
Updated for style.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob committed Sep 28, 2012
1 parent 92c4a6f commit b3572f8
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lib/FreshBooksRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ public function getGeneratedXML()
}

/*
* Send the request over the wire
* Send the request over the wire. Return result will be binary data if the FreshBooks response is
* a PDF, array if it is a normal request.
*
* @return binary data if response is a PDF, array if not
* @return mixed
*/
public function request()
{
Expand Down Expand Up @@ -178,13 +179,16 @@ public function request()
}

// With the new invoice.getPDF request, we sometimes have non-XML come through here
if (substr($result, 0, 4) == "%PDF"){
// it's a PDF file
$response = $result;
$this->_success = true;
} else {
$response = json_decode(json_encode(simplexml_load_string($result)), true);
$this->_success = ($response['@attributes']['status'] == 'ok');
if (substr($result, 0, 4) == "%PDF")
{
// it's a PDF file
$response = $result;
$this->_success = true;
}
else
{
$response = json_decode(json_encode(simplexml_load_string($result)), true);
$this->_success = ($response['@attributes']['status'] == 'ok');
}

$this->_response = $response;
Expand Down

0 comments on commit b3572f8

Please sign in to comment.