Skip to content

Commit b8f8bfd

Browse files
committed
merge all pull requests
Fix #93, #92,
1 parent 3882e86 commit b8f8bfd

12 files changed

+39
-52
lines changed

src/Core/Http/Serialization/XmlObjectSerializer.php

+6
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,12 @@ public function Deserialize($message, $bLimitToOne = false)
233233
$resultObjects = null;
234234

235235
$responseXmlObj = simplexml_load_string($message);
236+
237+
//handle count(*) case, for example Select count(*) from Invoice
238+
if(isset($responseXmlObj->attributes()['totalCount']) && !isset($responseXmlObj->attributes()['startPosition'])){
239+
return (int) $responseXmlObj->attributes()['totalCount'];
240+
}
241+
236242
foreach ($responseXmlObj as $oneXmlObj) {
237243
$oneXmlElementName = (string)$oneXmlObj->getName();
238244

src/Core/HttpClients/BaseCurl.php

-2
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,3 @@ public function close()
149149
$this->curl = null;
150150
}
151151
}
152-
153-
?>

src/Core/HttpClients/ClientFactory.php

-3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,3 @@ public static function createClient($clientName = CoreConstants::CLIENT_CURL){
5555
throw new SdkException("The client Name you passed is not supported. Please use either 'curl' or 'guzzle' for the client Name.");
5656
}
5757
}
58-
59-
60-
?>

src/Core/HttpClients/CurlHttpClient.php

-2
Original file line numberDiff line numberDiff line change
@@ -194,5 +194,3 @@ public function getLastResponse(){
194194
}
195195

196196
}
197-
198-
?>

src/Core/HttpClients/FaultHandler.php

-3
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,4 @@ public function getIntuitErrorMessage(){
292292
public function getIntuitErrorDetail(){
293293
return $this->intuitErrorDetail;
294294
}
295-
296-
297-
298295
}

src/Core/HttpClients/GuzzleHttpClient.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,4 @@ public function getLastResponse(){
121121
public function clearResponse(){
122122
$this->intuitResponse = false;
123123
}
124-
125-
}
126-
127-
?>
124+
}

src/Core/HttpClients/HttpClientInterface.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,4 @@ public function getLastResponse();
6060
* @param mix The response from the http client
6161
*/
6262
public function setIntuitResponse($response);
63-
}
64-
?>
63+
}

src/Core/OAuth/OAuth2/OAuth2AccessToken.php

-2
Original file line numberDiff line numberDiff line change
@@ -354,5 +354,3 @@ private function getDateFromSeconds($seconds){
354354
return date('Y/m/d H:i:s', $seconds);
355355
}
356356
}
357-
358-
?>

src/Core/OAuth/OAuth2/OAuth2LoginHelper.php

-2
Original file line numberDiff line numberDiff line change
@@ -389,5 +389,3 @@ private function constructRefreshTokenBody($refresh_token){
389389
return http_build_query($parameters);
390390
}
391391
}
392-
393-
?>

src/DataService/DataService.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public static function Configure($settings)
335335

336336
}
337337

338-
if($ServiceContext->IppConfiguration->OAuthMode = CoreConstants::OAUTH2)
338+
if($ServiceContext->IppConfiguration->OAuthMode == CoreConstants::OAUTH2)
339339
{
340340
$oauth2Config = $ServiceContext->IppConfiguration->Security;
341341
if($oauth2Config instanceof OAuth2AccessToken){
@@ -357,7 +357,8 @@ public static function Configure($settings)
357357
* @param OAuth2AccessToken $oauth2Conifg OAuth 2 Token related information
358358
* @param Array $settings The array that include the redirectURL, scope, state information
359359
*/
360-
private function configureOAuth2LoginHelper($oauth2Conifg, $settings){
360+
private function configureOAuth2LoginHelper($oauth2Conifg, $settings)
361+
{
361362
$refreshToken = CoreConstants::getRefreshTokenFromArray($settings);
362363
if(isset($refreshToken)){
363364
//Login helper for refresh token API call
@@ -385,15 +386,17 @@ private function configureOAuth2LoginHelper($oauth2Conifg, $settings){
385386
* Return the OAuth 2 Login Helper. The OAuth 2 Login helper can be used to generate OAuth code, get refresh Token, etc.
386387
* @return $OAuth2LoginHelper A helper to get OAuth 2 related values.
387388
*/
388-
public function getOAuth2LoginHelper(){
389+
public function getOAuth2LoginHelper()
390+
{
389391
return $this->OAuth2LoginHelper;
390392
}
391393

392394
/**
393395
* Update the OAuth 2 Token that will be used for API calls later.
394396
* @param OAuth2AccessToken $newOAuth2AccessToken The OAuth 2 Access Token that will be used later.
395397
*/
396-
public function updateOAuth2Token($newOAuth2AccessToken){
398+
public function updateOAuth2Token($newOAuth2AccessToken)
399+
{
397400
try{
398401
$this->serviceContext->updateOAuth2Token($newOAuth2AccessToken);
399402
$realmID = $newOAuth2AccessToken->getRealmID();
@@ -585,7 +588,7 @@ private function sendRequestParseResponseBodyAndHandleHttpError($entity, $uri, $
585588
$requestParameters = $this->getPostRequestParameters($uri, "multipart/form-data; boundary={$boundaryString}");
586589
break;
587590
case DataService::SENDEMAIL:
588-
$requestParameters = $this->getPostRequestParameters($uri . (is_null($email) ? '' : '?sendTo=' . $email), CoreConstants::CONTENTTYPE_OCTETSTREAM);
591+
$requestParameters = $this->getPostRequestParameters($uri . (is_null($email) ? '' : '?sendTo=' . urlencode($email)), CoreConstants::CONTENTTYPE_OCTETSTREAM);
589592
break;
590593
}
591594
//$restRequestHandler = new SyncRestHandler($this->serviceContext);

src/_Samples/CustomerCreate.php

+13-13
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,28 @@
99
use QuickBooksOnline\API\Facades\Customer;
1010

1111
// Prep Data Services
12-
12+
/*
1313
$dataService = DataService::Configure(array(
1414
'auth_mode' => 'oauth1',
1515
'consumerKey' => "qyprdUSoVpIHrtBp0eDMTHGz8UXuSz",
1616
'consumerSecret' => "TKKBfdlU1I1GEqB9P3AZlybdC8YxW5qFSbuShkG7",
17-
'accessTokenKey' => "lvprdBYrv22L2vEsSRJgcAeljxRkKdh0QLcYJDWcBU2GXVDE",
18-
'accessTokenSecret' => "T7F4DzbdU0bWWK5qIjZGEVhZEQytDEUM2XYASKnE",
17+
'accessTokenKey' => "qyprdxUakMagH93t01x1Z5wmIfIy3OiZcTqzI2EALXqhOaGE",
18+
'accessTokenSecret' => "QqQhCSvDgMvnJmoMbXI5d9TIVj9wKU1w4yIEaFNC",
1919
'QBORealmID' => "193514340994122",
2020
'baseUrl' => "https://sandbox-quickbooks.api.intuit.com"
2121
));
2222
23-
/*
23+
*/
2424
$dataService = DataService::Configure(array(
2525
'auth_mode' => 'oauth2',
26-
'ClientID' => "Q0lCkcEshsGMHOEula2r5RKc2yhxvMsYEpKN1lw1WZwyfd1Si6",
27-
'ClientSecret' => "gE0F9hLgwx9OBzRpNxyOvWJH6L2fIhzAwBugPJHq",
28-
'accessTokenKey' => "eyJlbmMiOiJBMTI4Q0JDLUhTMjU2IiwiYWxnIjoiZGlyIn0..JeoaEgWW8VjXoBfGABrGkQ.f0XFa7IKDumJ4fLhUPhnnFsZD2Rkon7t_kTcWJyrb1_4RLU4s8L5RB714Kw8zcc0Q5Bn48gGvLcotO6uKY2_MQ_D9l2RGUCO5NsFRAgr4NN4FO6WK-3sJp454Ck7AawoR86INEYW5GYFzgvqFwguQE9h4P0G1_6Ve3_3Vo8sjDKRXIY39SjT_3FfrShhsDSJXUCTahBE32wYYHltEQdy-Z4hRHVDjB4NM5sGaxsoWdpAzKhp60RC3xSV6IhniyJiGA-_DyzXVEhT7lORD50QJU-gwn1dmHB3MlfJryO4U-kMA3hrE6EXhgld6xQ27cUBERthObs2aV22tT-_0ZznwYUrFA9lbBWP5tK_KpzvcHsAD0ujQvaXEFqSemrm9KiPCT-7ZvZZR0bRd2cbL0tQ44PxsVe2I2d7QwZIJqa6U0DAl1GALlaNgkF96JToxiI8NRrndZoEYDvepa8cf6PVt2O8KUwmmeTvpjgkQ7ucX68e81xN9R19MdAj8Mu46i40k-m4VK1UPpZ_cGuqLQojFiOerivOy_hJjalo2KWdLQYD9N_s5dfLH_BAB1ElVz5dPHz1aIPe_sxvc2VQEBkCu4xtmE0g4oLNszhD_Kh7-U7hK6RA5y7RQUGaZ1L05-9YIi5-XBx4FuVkYK3MZTqbHf9cmq6asAGvNNRKVe5mXOZeskZp25OUVU-QUHfFo_Pd.Rq4OPgznx4GamOXKam6Y1g",
29-
'refreshTokenKey' => 'Q01150906066615eVPaXZ1bJn7WhLJVu1cN0ngQXZeI5X1QziK',
30-
'QBORealmID' => "123145857569084",
31-
'baseUrl' => "https://sandbox-quickbooks.api.intuit.com"
26+
'ClientID' => "Q0fXL014zAv3wzmlhwXMEHTrKepfAshCRjztEu58ZokzCD5T7D",
27+
'ClientSecret' => "stfnZfuSZUDay6cJSWtvQ9HkWiKFbcI9YuBTET5P",
28+
'accessTokenKey' => "eyJlbmMiOiJBMTI4Q0JDLUhTMjU2IiwiYWxnIjoiZGlyIn0..lmGChkCAJYTxucq_gspS8A.of6yijgWgpPQ744zAoQZHL3ePKpF8b9UrAX9BB7Pp94-52acJgvTLaiJwSpbxTHs1S-1ap3WokLxL44_dciUANbSeqLvn6gf_oSv3TSNT_Za4j72Pl6kR8-VAcmYqIB75VLTvXA65qrPYirKRxsdJLs-WzzIEab6n5rNJo2DzAgqUIkir__ltf3JBOLvaaz3Hp40KvZaVQG0cl2w60DfIs-fjZwhzJG5FKSorw-_TCg1xmxbJXC6bZBntbo-OwiL5yJ8_FAsPcNo2d-sONhltN7zBug6M_dJ8Ptj3GhOJh8V16LUC0BFvvTncWTyiRPG8yDcq1Ngm172aDIw5jlL5UzW0hS8GarOGGUjWIc4nO_Zvvn1NwP06-1cL7Mb7HNJ4CgG9EjotqLHK07DEegQO5NZTRRE3lQfjtndcb4g2EsQJrThy6d412DD9UIwK-mm8gIch3skATvnDskWkP_fegmaAvd40jSMptPVt4_ujy-55CmZHk46QwjCJTiiSrh6kid--QewudVC9Mz6y3nnjEfEWZpsFcuuU7omghu-Ds-aoW94pYrKLTWcDd56S4moT9VFcvJGK5Ew_5HT6eavNvFhcO376mdkeYGxFJ7o4-i-4vCv27H-3KH4147yAheSJ0dqvjNxyFTCfULKPm2kgjz8LpcIi2wxLpShG7wgoe9ldcYUQTyDZ8wME6qgUR95.xczznGp9u2s1likp8jOhaQ",
29+
'refreshTokenKey' => 'Q0115201062198zx1lpp6MpzcYOqWbwqbHVJGfy0ledlb6A9Z8',
30+
'QBORealmID' => "193514611894164",
31+
'baseUrl' => "development"
3232
));
33-
*/
33+
3434
$dataService->setLogLocation("/Users/hlu2/Desktop/newFolderForLog");
3535

3636

@@ -51,7 +51,7 @@
5151
"Suffix"=> "Jr",
5252
"FullyQualifiedName"=> "Evil King",
5353
"CompanyName"=> "King Evial",
54-
"DisplayName"=> "Evil King",
54+
"DisplayName"=> "Evil King Sr2",
5555
"PrimaryPhone"=> [
5656
"FreeFormNumber"=> "(555) 555-5555"
5757
],
@@ -61,7 +61,7 @@
6161
]);
6262
$resultingCustomerObj = $dataService->Add($customerObj);
6363
$error = $dataService->getLastError();
64-
if ($error != null) {
64+
if ($error) {
6565
echo "The Status code is: " . $error->getHttpStatusCode() . "\n";
6666
echo "The Helper message is: " . $error->getOAuthHelperError() . "\n";
6767
echo "The Response message is: " . $error->getResponseBody() . "\n";

src/_Samples/CustomerQuery.php

+10-14
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,28 @@
1010

1111
// Prep Data Services
1212
$dataService = DataService::Configure(array(
13-
'auth_mode' => 'oauth1',
14-
'consumerKey' => "lve2eZN6ZNBrjN0Wp26JVYJbsOOFbF",
15-
'consumerSecret' => "fUhPIeu6jrq1UmNGXSMsIsl0JaHuHzSkFf3tsmrW",
16-
'accessTokenKey' => "qye2etcpyquO3B1t8ydZJI8OTelqJCMiLZlY5LdX7qZunwoo",
17-
'accessTokenSecret' => "2lEUtSEIvXf64CEkMLaGDK5rCwaxE9UvfW1dYrrH",
18-
'QBORealmID' => "193514489870599",
19-
'baseUrl' => "https://qbonline-e2e.api.intuit.com/"
13+
'auth_mode' => 'oauth2',
14+
'ClientID' => "Q0fXL014zAv3wzmlhwXMEHTrKepfAshCRjztEu58ZokzCD5T7D",
15+
'ClientSecret' => "stfnZfuSZUDay6cJSWtvQ9HkWiKFbcI9YuBTET5P",
16+
'accessTokenKey' => "eyJlbmMiOiJBMTI4Q0JDLUhTMjU2IiwiYWxnIjoiZGlyIn0..lmGChkCAJYTxucq_gspS8A.of6yijgWgpPQ744zAoQZHL3ePKpF8b9UrAX9BB7Pp94-52acJgvTLaiJwSpbxTHs1S-1ap3WokLxL44_dciUANbSeqLvn6gf_oSv3TSNT_Za4j72Pl6kR8-VAcmYqIB75VLTvXA65qrPYirKRxsdJLs-WzzIEab6n5rNJo2DzAgqUIkir__ltf3JBOLvaaz3Hp40KvZaVQG0cl2w60DfIs-fjZwhzJG5FKSorw-_TCg1xmxbJXC6bZBntbo-OwiL5yJ8_FAsPcNo2d-sONhltN7zBug6M_dJ8Ptj3GhOJh8V16LUC0BFvvTncWTyiRPG8yDcq1Ngm172aDIw5jlL5UzW0hS8GarOGGUjWIc4nO_Zvvn1NwP06-1cL7Mb7HNJ4CgG9EjotqLHK07DEegQO5NZTRRE3lQfjtndcb4g2EsQJrThy6d412DD9UIwK-mm8gIch3skATvnDskWkP_fegmaAvd40jSMptPVt4_ujy-55CmZHk46QwjCJTiiSrh6kid--QewudVC9Mz6y3nnjEfEWZpsFcuuU7omghu-Ds-aoW94pYrKLTWcDd56S4moT9VFcvJGK5Ew_5HT6eavNvFhcO376mdkeYGxFJ7o4-i-4vCv27H-3KH4147yAheSJ0dqvjNxyFTCfULKPm2kgjz8LpcIi2wxLpShG7wgoe9ldcYUQTyDZ8wME6qgUR95.xczznGp9u2s1likp8jOhaQ",
17+
'refreshTokenKey' => 'Q0115201062198zx1lpp6MpzcYOqWbwqbHVJGfy0ledlb6A9Z8',
18+
'QBORealmID' => "193514611894164",
19+
'baseUrl' => "development"
2020
));
2121

2222
$dataService->setLogLocation("/Users/hlu2/Desktop/newFolderForLog");
2323

2424
// Run a query
25-
$entities = $dataService->Query("SELECT * FROM Customer");
25+
$entities = $dataService->Query("Select count(*) from Invoice");
2626
$error = $dataService->getLastError();
27-
if ($error != null) {
27+
if ($error) {
2828
echo "The Status code is: " . $error->getHttpStatusCode() . "\n";
2929
echo "The Helper message is: " . $error->getOAuthHelperError() . "\n";
3030
echo "The Response message is: " . $error->getResponseBody() . "\n";
3131
exit();
3232
}
3333
// Echo some formatted output
34-
$i = 0;
35-
foreach ($entities as $oneCustomer) {
36-
echo "Customer[$i] DisplayName: {$oneCustomer->DisplayName} (Created at {$oneCustomer->MetaData->CreateTime})\n";
37-
$i++;
38-
}
34+
var_dump($entities);
3935

4036
/*
4137
Example output:

0 commit comments

Comments
 (0)