Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
hlu2 committed Mar 23, 2018
2 parents 5c919f8 + cb79f17 commit fe42e40
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 10 deletions.
16 changes: 7 additions & 9 deletions docs/_sources/quickstart.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,8 @@ Here is the Complete example and what the result looks like in QuickBooks Online
'accessTokenSecret' => "JqkHSBKzNHbqjMq0Njbcq8fjgJSpfjMvqHVWnDOW",
'QBORealmID' => "193514464689044",
'baseUrl' => "Development"
));
$dataService->setLogLocation("/Users/hlu2/Desktop/newFolderForLog");
$dataService->throwExceptionOnError(true);
))->setLogLocation("/Users/hlu2/Desktop/newFolderForLog")
->throwExceptionOnError(true);
//Add a new Invoice
$invoiceToCreate = Invoice::create([
"DocNumber" => "101",
Expand Down Expand Up @@ -260,9 +259,8 @@ Many QuickBooks Online users need to create entities with Tax. It is achieved on
'refreshTokenKey' => "L011529104721Bb4GIrEKlXQ03Zw8pyGAHSsVxUt3prTKiNoVO",
'QBORealmID' => "193514708967874",
'baseUrl' => "Production"
));
$dataService->setLogLocation("/Users/hlu2/Desktop/newFolderForLog");
$dataService->throwExceptionOnError(true);
))->setLogLocation("/Users/hlu2/Desktop/newFolderForLog")
->throwExceptionOnError(true);
//Add a new Invoice
$invoiceToCreate = Invoice::create([
"DocNumber" => "101",
Expand Down Expand Up @@ -1101,9 +1099,9 @@ In V3 PHP SDK, the report service is separate from data service. To use the Repo
}
$reportService->setStartDate("2015-01-01");
$reportService->setAccountingMethod("Accrual");
$profitAndLossReport = $reportService->executeReport(ReportName::PROFITANDLOSS);
$profitAndLossReport = $reportService->setStartDate("2015-01-01")
->setAccountingMethod("Accrual")
->executeReport(ReportName::PROFITANDLOSS);
if (!$profitAndLossReport) {
exit("ProfitAndLossReport Is Null.\n");
} else {
Expand Down
30 changes: 29 additions & 1 deletion src/DataService/DataService.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,13 @@ public function updateServiceContextSettingsForOthers($serviceContext)
/**
* Set or Update the ServiceContext of this DataService.
*
* @var ServiceContext $serviceContext The new ServiceContext passed by.
* @var ServiceContext $serviceContext The new ServiceContext passed by.
* @return $this
*/
private function setupServiceContext($serviceContext)
{
$this->serviceContext = $serviceContext;
return $this;
}

/**
Expand All @@ -201,6 +203,7 @@ public function getServiceContext()
* Set the SyncRest Handler for the DataService. If the client Name changed, the underlying Client that SyncRestHandler used will also changed.
*
* @var ServiceContext $serviceContext The service Context for this DataService
* @return $this
*
*/
protected function setupRestHandler($serviceContext)
Expand All @@ -211,6 +214,7 @@ protected function setupRestHandler($serviceContext)
}else{
throw new SdkException("Can not set the Rest Client based on null ServiceContext.");
}
return $this;
}

/**
Expand All @@ -222,56 +226,71 @@ public function getClientName(){
}
/**
* PHP SDK currently only support XML for Object Serialization and Deserialization, except for Report Service
*
* @return $this
*/
public function useXml()
{
$serviceContext = $this->getServiceContext();
$serviceContext->useXml();
$this->updateServiceContextSettingsForOthers($serviceContext);
return $this;
}

/**
* PHP SDK currently only support XML for Object Serialization and Deserialization, except for Report Service
*
* @return $this
*/
public function useJson()
{
$serviceContext = $this->getServiceContext();
$serviceContext->useJson();
$this->updateServiceContextSettingsForOthers($serviceContext);
return $this;
}

/**
* Set a new directory for request and response log
*
* @param String $new_log_location The directory path for storing request and response log
*
* @return $this
*/
public function setLogLocation($new_log_location)
{
$serviceContext = $this->getServiceContext();
$serviceContext->setLogLocation($new_log_location);
$this->updateServiceContextSettingsForOthers($serviceContext);
return $this;
}

/**
* Set a new Minor Version
*
* @param String $newMinorVersion The new minor version that passed
*
* @return $this
*/
public function setMinorVersion($newMinorVersion)
{
$serviceContext = $this->getServiceContext();
$serviceContext->setMinorVersion($newMinorVersion);
$this->updateServiceContextSettingsForOthers($serviceContext);
return $this;
}

/**
* Disable the logging function
*
* @return $this
*/
public function disableLog()
{
$serviceContext = $this->getServiceContext();
$serviceContext->disableLog();
$this->updateServiceContextSettingsForOthers($serviceContext);
return $this;
}


Expand Down Expand Up @@ -301,12 +320,16 @@ public function getClinetName(){

/**
* The client Name can be either 'curl', 'guzzle', or 'guzzlehttp'.
*
* @param String $clientName The client Name used by the service
*
* @return $this
*/
public function setClientName($clientName){
$this->clientName = $clientName;
$serviceContext = $this->getServiceContext();
$this->setupRestHandler($serviceContext);
return $this;
}

/**
Expand Down Expand Up @@ -395,7 +418,10 @@ public function getOAuth2LoginHelper()

/**
* Update the OAuth 2 Token that will be used for API calls later.
*
* @param OAuth2AccessToken $newOAuth2AccessToken The OAuth 2 Access Token that will be used later.
*
* @return $this
*/
public function updateOAuth2Token($newOAuth2AccessToken)
{
Expand All @@ -407,6 +433,7 @@ public function updateOAuth2Token($newOAuth2AccessToken)
} catch (SdkException $e){
echo $e->getTraceAsString();
}
return $this;
}

/**
Expand Down Expand Up @@ -434,6 +461,7 @@ private function useMinorVersion()
if (is_numeric($version) && !empty($version)) {
$this->serviceContext->minorVersion = $version;
}
return $this;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/DataService/IntuitBatchResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,12 @@ public function AddEntities($entity)
/**
* Set the Entities to an entity list
* @param Array $newEntities
*
* @return $this
*/
public function setEntities($newEntities){
$this->entities = $newEntities;
return $this;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/Diagnostics/ContentWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ public function __construct($content = null)
* Set prefix for a temporary filename.
* It is used only by saveTemp()
* @param string $prefix
*
* @return $this
*/
public function setPrefix($prefix)
{
$this->prefix = $prefix;
return $this;
}

/**
Expand Down
Loading

0 comments on commit fe42e40

Please sign in to comment.