Skip to content

Commit 862c6d2

Browse files
Merge pull request #355 from intuit/feature/v1942
Release: v1942 - minorverison=54
2 parents 251914e + 069f8d3 commit 862c6d2

11 files changed

+737
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ composer.phar
33
/nbproject
44
.DS_Store
55
.idea
6+

src/Core/CoreConstants.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class CoreConstants
88
{
99
//Set the default minor version
10-
const DEFAULT_SDK_MINOR_VERSION = "53";
10+
const DEFAULT_SDK_MINOR_VERSION = "54";
1111
const DEFAULT_LOGGINGLOCATION = "/tmp/IdsLogs";
1212

1313
const PHP_CLASS_PREFIX = 'IPP';
@@ -298,7 +298,7 @@ class CoreConstants
298298
* The Request source header value.
299299
* @var string REQUESTSOURCEHEADER
300300
*/
301-
const USERAGENT = "V3PHPSDK5.4.3";
301+
const USERAGENT = "V3PHPSDK5.4.4";
302302

303303
public static function getType($string, $return=1)
304304
{

src/Data/IPPCreditCardPaymentTxn.php

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,52 @@ public function __construct($keyValInitializers=array(), $verbose=FALSE)
7171
*/
7272
public $Amount;
7373
/**
74-
* @Definition Internal use only: extension place holder for
75-
CreditCardPayment
74+
* @Definition
75+
Product: ALL
76+
Description: Specifies the vendor reference for this transaction.
77+
78+
* @xmlType element
79+
* @xmlNamespace http://schema.intuit.com/finance/v3
80+
* @xmlMinOccurs 0
81+
* @xmlName VendorRef
82+
* @var com\intuit\schema\finance\v3\IPPReferenceType
83+
*/
84+
public $VendorRef;
85+
/**
86+
* @Definition
87+
Product: ALL
88+
Description: The check number printed on the check.
89+
90+
* @xmlType element
91+
* @xmlNamespace http://schema.intuit.com/finance/v3
92+
* @xmlMinOccurs 0
93+
* @xmlName CheckNum
94+
* @var string
95+
*/
96+
public $CheckNum;
97+
/**
98+
* @Definition PrintStatus if to be printed or already printed.
99+
100+
* @xmlType element
101+
* @xmlNamespace http://schema.intuit.com/finance/v3
102+
* @xmlMinOccurs 0
103+
* @xmlName PrintStatus
104+
* @var com\intuit\schema\finance\v3\IPPPrintStatusEnum
105+
*/
106+
public $PrintStatus;
107+
/**
108+
* @Definition Memo associated with the Credit Card Payment transaction.
109+
110+
* @xmlType element
111+
* @xmlNamespace http://schema.intuit.com/finance/v3
112+
* @xmlMinOccurs 0
113+
* @xmlName Memo
114+
* @var string
115+
*/
116+
public $Memo;
117+
/**
118+
* @Definition Internal use only: extension place holder for CreditCardPayment
119+
76120
* @xmlType element
77121
* @xmlNamespace http://schema.intuit.com/finance/v3
78122
* @xmlName CreditCardPaymentEx

src/Data/IPPEntityStatusEnum.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
* @xmlType string
77
* @xmlName IPPEntityStatusEnum
88
* @var IPPEntityStatusEnum
9-
* @xmlDefinition Object failed to sync to QuickBooks
9+
* @xmlDefinition
10+
Product: ALL
11+
Description: Possible Status of an Entity.
12+
1013
*/
1114
class IPPEntityStatusEnum
1215
{

src/DataService/DataService.php

Lines changed: 169 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
use QuickBooksOnline\API\Core\CoreHelper;
2020
use QuickBooksOnline\API\Core\Http\Serialization\IEntitySerializer;
21+
use QuickBooksOnline\API\Core\Http\Serialization\XmlObjectSerializer;
2122
use QuickBooksOnline\API\Core\HttpClients\FaultHandler;
2223
use QuickBooksOnline\API\Core\HttpClients\RestHandler;
2324
use QuickBooksOnline\API\Core\ServiceContext;
@@ -29,6 +30,7 @@
2930
use QuickBooksOnline\API\Data\IPPAttachable;
3031
use QuickBooksOnline\API\Data\IPPEntitlementsResponse;
3132
use QuickBooksOnline\API\Data\IPPIntuitEntity;
33+
use QuickBooksOnline\API\Data\IPPRecurringTransaction;
3234
use QuickBooksOnline\API\Data\IPPTaxService;
3335
use QuickBooksOnline\API\Data\IPPid;
3436
use QuickBooksOnline\API\Exception\IdsException;
@@ -803,7 +805,6 @@ public function Add($entity)
803805
}
804806

805807
$httpsPostBody = $this->executeObjectSerializer($entity, $urlResource);
806-
807808
// Builds resource Uri
808809
$resourceURI = implode(CoreConstants::SLASH_CHAR, array('company', $this->serviceContext->realmId, $urlResource));
809810

@@ -1193,6 +1194,67 @@ public function CDC($entityList, $changedSince)
11931194
}
11941195
}
11951196

1197+
/**
1198+
* Creates a RecurringTransaction Entity under the specified realm. The realm must be set in the context.
1199+
*
1200+
* @param IPPIntuitEntity $entity Entity to Create.
1201+
* @return IntuitRecurringTransactionResponse Returns the RecurringTransaction created for the entity.
1202+
* @throws IdsException
1203+
*/
1204+
public function addRecurringTxn($entity)
1205+
{
1206+
$this->serviceContext->IppConfiguration->Logger->RequestLog->Log(TraceLevel::Info, "Called Method Add.");
1207+
1208+
// Validate parameter
1209+
if (!$entity) {
1210+
$this->serviceContext->IppConfiguration->Logger->RequestLog->Log(TraceLevel::Error, "Argument Null Exception");
1211+
throw new IdsException('Argument Null Exception');
1212+
}
1213+
// Verify operation access
1214+
$this->verifyOperationAccess($entity, __FUNCTION__);
1215+
if ($this->isJsonOnly($entity)) {
1216+
$this->forceJsonSerializers();
1217+
}
1218+
// Create recurring transaction object
1219+
$recurringtxn = RecurringTransactionAdapter::createRecurringTransactionObject($entity);
1220+
1221+
// Create recurring transaction Post Body
1222+
$httpsPostBody = RecurringTransactionAdapter::getRecurringTxnBody($recurringtxn);
1223+
1224+
// Builds resource Uri
1225+
$resourceURI = implode(CoreConstants::SLASH_CHAR, array('company', $this->serviceContext->realmId, 'recurringtransaction'));
1226+
1227+
$requestParameters = new RequestParameters($resourceURI, 'POST', CoreConstants::CONTENTTYPE_APPLICATIONXML, null);
1228+
$restRequestHandler = $this->getRestHandler();
1229+
list($responseCode, $responseBody) = $restRequestHandler->sendRequest($requestParameters, $httpsPostBody, null, $this->isThrownExceptionOnError());
1230+
$faultHandler = $restRequestHandler->getFaultHandler();
1231+
if ($faultHandler) {
1232+
$this->lastError = $faultHandler;
1233+
return null;
1234+
} else {
1235+
$this->lastError = false;
1236+
$returnValue = new IntuitRecurringTransactionResponse();
1237+
try {
1238+
$xmlObj = simplexml_load_string($responseBody);
1239+
// deserialize the response body
1240+
$deserializedResponse = $this->responseSerializer->Deserialize($xmlObj->RecurringTransaction->asXML(), false);
1241+
$entityName = XmlObjectSerializer::cleanPhpClassNameToIntuitEntityName(get_class($entity));
1242+
$returnValue->entities[$entityName] = $deserializedResponse;
1243+
} catch (\Exception $e) {
1244+
IdsExceptionManager::HandleException($e);
1245+
}
1246+
$this->serviceContext->IppConfiguration->Logger->CustomLogger->Log(TraceLevel::Info, "Finished Executing Recurring Transaction.");
1247+
return $returnValue;
1248+
}
1249+
}
1250+
1251+
/**
1252+
* Query RecurringTransaction Entity under the specified realm. The realm must be set in the context.
1253+
*
1254+
* @param query ex : SELECT * FROM RecurringTransaction
1255+
* @return IntuitRecurringTransactionResponse Returns the RecurringTransaction created for the entity.
1256+
* @throws IdsException
1257+
*/
11961258
public function recurringTransaction($query)
11971259
{
11981260
$this->serviceContext->IppConfiguration->Logger->RequestLog->Log(TraceLevel::Info, "Called Method Query.");
@@ -1244,6 +1306,112 @@ public function recurringTransaction($query)
12441306
}
12451307
}
12461308

1309+
/**
1310+
* Find a RecurringTransaction Entity By ID under the specified realm. The realm must be set in the context.
1311+
*
1312+
* @param $Id Id of the IPPIntuitEntity Object
1313+
* @return IntuitRecurringTransactionResponse Returns the RecurringTransaction created for the entity.
1314+
* @throws IdsException
1315+
*/
1316+
public function findRecurringTransactionById($Id = null)
1317+
{
1318+
$this->serviceContext->IppConfiguration->Logger->RequestLog->Log(TraceLevel::Info, "Called Method findRecurringTransactionById.");
1319+
1320+
if (!$Id) {
1321+
$this->serviceContext->IppConfiguration->Logger->RequestLog->Log(TraceLevel::Error, "Argument Null Exception");
1322+
throw new IdsException('Argument [Id] Null Exception');
1323+
}
1324+
1325+
// Builds resource Uri
1326+
$resourceURI = implode(CoreConstants::SLASH_CHAR, array('company', $this->serviceContext->realmId, 'recurringtransaction/'. $Id));
1327+
1328+
// Make the GET request to fetch the recurring transaction
1329+
$requestParameters = new RequestParameters($resourceURI, 'GET', CoreConstants::CONTENTTYPE_APPLICATIONXML, null);
1330+
$restRequestHandler = $this->getRestHandler();
1331+
list($responseCode, $responseBody) = $restRequestHandler->sendRequest($requestParameters, null, null, $this->isThrownExceptionOnError());
1332+
$faultHandler = $restRequestHandler->getFaultHandler();
1333+
//$faultHandler now is true or false
1334+
if ($faultHandler) {
1335+
$this->lastError = $faultHandler;
1336+
return null;
1337+
} else {
1338+
//clean the error
1339+
$this->lastError = false;
1340+
$returnValue = new IntuitRecurringTransactionResponse();
1341+
try {
1342+
$xmlObj = simplexml_load_string($responseBody);
1343+
1344+
// deserialize the response body
1345+
$deserializedResponse = $this->responseSerializer->Deserialize($xmlObj->RecurringTransaction->asXML(), false);
1346+
$entityName = XmlObjectSerializer::cleanPhpClassNameToIntuitEntityName(get_class($deserializedResponse[0]));
1347+
$returnValue->entities[$entityName] = $deserializedResponse;
1348+
} catch (\Exception $e) {
1349+
IdsExceptionManager::HandleException($e);
1350+
}
1351+
$this->serviceContext->IppConfiguration->Logger->CustomLogger->Log(TraceLevel::Info, "Finished Executing Recurring Transaction.");
1352+
return $returnValue;
1353+
}
1354+
}
1355+
1356+
/**
1357+
* Find a RecurringTransaction Entity By ID under the specified realm. The realm must be set in the context.
1358+
*
1359+
* @param IntuitRecurringTransactionResponse RecurringTransaction Response from findRecurringTransactionById method.
1360+
* @return IntuitRecurringTransactionResponse Returns the RecurringTransaction created for the entity.
1361+
* @throws IdsException
1362+
*/
1363+
public function deleteRecurringTransaction($recurringTransaction)
1364+
{
1365+
$this->serviceContext->IppConfiguration->Logger->RequestLog->Log(TraceLevel::Info, "Called Method Delete.");
1366+
1367+
// Validate parameter
1368+
if (!$recurringTransaction) {
1369+
$this->serviceContext->IppConfiguration->Logger->RequestLog->Log(TraceLevel::Error, "Argument Null Exception");
1370+
throw new IdsException('Argument Null Exception');
1371+
}
1372+
$this->verifyOperationAccess($recurringTransaction, __FUNCTION__);
1373+
1374+
// Get the Entity Name from $recurringTransaction
1375+
$entityName = array_keys($recurringTransaction->entities)[0];
1376+
1377+
// Get the IPPEntity Object from $recurringTransaction
1378+
$entity = $recurringTransaction->entities[$entityName][0];
1379+
1380+
// Create recurring transaction object
1381+
$recurringtxn = RecurringTransactionAdapter::createRecurringTransactionObject($entity);
1382+
// Create recurring transaction Post Body
1383+
$httpsPostBody = RecurringTransactionAdapter::getRecurringTxnBody($recurringtxn);
1384+
1385+
// Builds resource Uri
1386+
$resourceURI = implode(CoreConstants::SLASH_CHAR, array('company', $this->serviceContext->realmId, 'recurringtransaction' . '?operation=delete'));
1387+
1388+
// Make the GET request to fetch the recurring transaction
1389+
$requestParameters = new RequestParameters($resourceURI, 'POST', CoreConstants::CONTENTTYPE_APPLICATIONXML, null);
1390+
$restRequestHandler = $this->getRestHandler();
1391+
list($responseCode, $responseBody) = $restRequestHandler->sendRequest($requestParameters, $httpsPostBody, null, $this->isThrownExceptionOnError());
1392+
$faultHandler = $restRequestHandler->getFaultHandler();
1393+
//$faultHandler now is true or false
1394+
if ($faultHandler) {
1395+
$this->lastError = $faultHandler;
1396+
return null;
1397+
} else {
1398+
//clean the error
1399+
$this->lastError = false;
1400+
$returnValue = new IntuitRecurringTransactionResponse();
1401+
try {
1402+
$xmlObj = simplexml_load_string($responseBody);
1403+
1404+
// deserialize the response body
1405+
$deserializedResponse = $this->responseSerializer->Deserialize($xmlObj->RecurringTransaction->asXML(), false);
1406+
$entityName = XmlObjectSerializer::cleanPhpClassNameToIntuitEntityName(get_class($entity));
1407+
$returnValue->entities[$entityName] = $deserializedResponse;
1408+
} catch (\Exception $e) {
1409+
IdsExceptionManager::HandleException($e);
1410+
}
1411+
$this->serviceContext->IppConfiguration->Logger->CustomLogger->Log(TraceLevel::Info, "Finished Executing Recurring Transaction.");
1412+
return $returnValue;
1413+
}
1414+
}
12471415

12481416
/**
12491417
* Returns an entity under the specified realm. The realm must be set in the context.
@@ -1266,7 +1434,6 @@ public function Retrieve($entity)
12661434
*/
12671435
protected function executeObjectSerializer($entity, &$urlResource)
12681436
{
1269-
//
12701437
$result = $this->getRequestSerializer()->Serialize($entity);
12711438
$urlResource = $this->getRequestSerializer()->getResourceURL();
12721439

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
namespace QuickBooksOnline\API\DataService;
3+
4+
use QuickBooksOnline\API\Core\CoreHelper;
5+
use QuickBooksOnline\API\Core\Http\Serialization\IEntitySerializer;
6+
use QuickBooksOnline\API\Core\Http\Serialization\XmlObjectSerializer;
7+
use QuickBooksOnline\API\Core\HttpClients\FaultHandler;
8+
use QuickBooksOnline\API\Core\HttpClients\RestHandler;
9+
use QuickBooksOnline\API\Core\ServiceContext;
10+
use QuickBooksOnline\API\Data\IPPRecurringTransaction;
11+
12+
/**
13+
* @xmlNamespace http://schema.intuit.com/finance/v3
14+
* @xmlType IntuitEntity
15+
* @xmlName IPPRecurringTransaction
16+
* @var IPPRecurringTransaction
17+
* @xmlDefinition The Recurrence Transaction Object
18+
*/
19+
20+
21+
/**
22+
* AdapterClass for recurring transaction
23+
*/
24+
class RecurringTransactionAdapter
25+
{
26+
27+
/**
28+
* service context object.
29+
* @var ServiceContext serviceContext
30+
*/
31+
private $serviceContext;
32+
33+
/**
34+
* rest handler object.
35+
* @var RestHandler restHandler
36+
*/
37+
private $restHandler;
38+
39+
/**
40+
* serializer to be used.
41+
* @var IEntitySerializer responseSerializer
42+
*/
43+
private $responseSerializer;
44+
45+
/**
46+
* Throw Exception on Error or not. Default is false.
47+
* @var boolean
48+
*/
49+
private $isThrowExceptionOnError = false;
50+
51+
/**
52+
* Initializes a new instance of the RecurringTransactionAdapter class.
53+
* @param $serviceContext The service context.
54+
* @param $restHandler The rest handler.
55+
*/
56+
public function __construct($serviceContext, $restHandler, $isThrowExceptionOnError)
57+
{
58+
$this->serviceContext = $serviceContext;
59+
$this->restHandler = $restHandler;
60+
$this->isThrowExceptionOnError = $isThrowExceptionOnError;
61+
$this->responseSerializer = CoreHelper::GetSerializer($this->serviceContext, false);
62+
}
63+
64+
public static function createRecurringTransactionObject($entity)
65+
{
66+
$recurringtxn = new IPPRecurringTransaction();
67+
$recurringtxn->IntuitObject = $entity;
68+
return $recurringtxn;
69+
}
70+
71+
public static function getRecurringTxnBody($entity)
72+
{
73+
$httpsPostBody = XmlObjectSerializer::getPostXmlFromArbitraryEntity($entity, $urlResource);
74+
$entityName = self::getEntityName($entity);
75+
$httpsPostBody = str_replace('IntuitObject','ns0:'.$entityName,$httpsPostBody);
76+
return $httpsPostBody;
77+
}
78+
79+
public static function getEntityName($entity)
80+
{
81+
$xmlEntityName = XmlObjectSerializer::cleanPhpClassNameToIntuitEntityName(get_class($entity->IntuitObject));
82+
return $xmlEntityName;
83+
}
84+
}

src/Facades/FacadeClassMapper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ public static function OtherAntiPatternNameEntity(){
190190
'PurchaseTaxRateList' => 'TaxRateList',
191191
'AdjustmentTaxRateList' => 'TaxRateList',
192192
//Use JournalEntryEntity to replace Entity
193-
'JournalEntryEntity' => 'EntityTypeRef'
193+
'JournalEntryEntity' => 'EntityTypeRef',
194+
'ScheduleInfo' => 'RecurringScheduleInfo'
194195
];
195196
}
196197

0 commit comments

Comments
 (0)