iSDK

The Contact Form 7 - Infusionsoft Add-on iSDK class.

Defined (1)

The class is defined in the following location(s).

/src/isdk.php  
  1. class iSDK 
  2.  
  3. static private $handle; 
  4. public $logname = ''; 
  5. public $loggingEnabled = 0; 
  6.  
  7. /** 
  8. * @method cfgCon 
  9. * @description Creates and tests the API Connection to the Application 
  10. * @param $name - Application Name 
  11. * @param string $key - API Key 
  12. * @param string $dbOn - Error Handling On 
  13. * @param string $type - Infusionsoft or Mortgage Pro 
  14. * @return bool 
  15. * @throws iSDKException 
  16. */ 
  17. public function cfgCon($name, $key = "", $dbOn = "on") 
  18. $this->debug = (($key == 'on' || $key == 'off' || $key == 'kill' || $key == 'throw') ? $key : $dbOn); 
  19.  
  20. if ($key != "" && $key != "on" && $key != "off" && $key != 'kill' && $key != 'throw') { 
  21. $this->key = $key; 
  22. } else { 
  23. include('conn.cfg.php'); 
  24. $appLines = $connInfo; 
  25. foreach ($appLines as $appLine) { 
  26. $details[substr($appLine, 0, strpos($appLine, ":"))] = explode(":", $appLine); 
  27. $appname = $details[$name][1]; 
  28. $this->key = $details[$name][3]; 
  29.  
  30. if (!isset($appname)) { 
  31. $appname = $name; 
  32.  
  33. $this->client = new xmlrpc_client("https://$appname.infusionsoft.com/api/xmlrpc"); 
  34.  
  35. /** Return Raw PHP Types */ 
  36. $this->client->return_type = "phpvals"; 
  37.  
  38. /** SSL Certificate Verification */ 
  39. $this->client->setSSLVerifyPeer(TRUE); 
  40. $this->client->setCaCertificate((__DIR__ != '__DIR__' ? __DIR__ : dirname(__FILE__)) . '/infusionsoft.pem'); 
  41. //$this->client->setDebug(2); 
  42.  
  43. $this->encKey = php_xmlrpc_encode($this->key); 
  44.  
  45. /** Connection verification */ 
  46.  
  47. try { 
  48. $connected = $this->dsGetSetting("Application", "enabled"); 
  49.  
  50. if (strpos($connected, 'ERROR') !== FALSE) { 
  51. throw new iSDKException($connected); 
  52.  
  53. } catch (iSDKException $e) { 
  54. throw new iSDKException($e->getMessage()); 
  55.  
  56. return true; 
  57.  
  58. /** 
  59. * @method getTemporaryKey 
  60. * @description Connect and Obtain an API key from a vendor key 
  61. * @param string $name - Application Name 
  62. * @param string $user - Username 
  63. * @param string $pass - Password 
  64. * @param string $key - Vendor Key 
  65. * @param string $dbOn - Error Handling On 
  66. * @return bool 
  67. * @throws iSDKException 
  68. */ 
  69. public function vendorCon($name, $user, $pass, $key = "", $dbOn = "on") 
  70. $this->debug = (($key == 'on' || $key == 'off' || $key == 'kill' || $key == 'throw') ? $key : $dbOn); 
  71.  
  72. if ($key != "" && $key != "on" && $key != "off" && $key != 'kill' && $key != 'throw') { 
  73. $this->client = new xmlrpc_client("https://$name.infusionsoft.com/api/xmlrpc"); 
  74. $this->key = $key; 
  75. } else { 
  76. include('conn.cfg.php'); 
  77. $appLines = $connInfo; 
  78. foreach ($appLines as $appLine) { 
  79. $details[substr($appLine, 0, strpos($appLine, ":"))] = explode(":", $appLine); 
  80. if (!empty($details[$name])) { 
  81. if ($details[$name][2] == "i") { 
  82. $this->client = new xmlrpc_client("https://" . $details[$name][1] . 
  83. ".infusionsoft.com/api/xmlrpc"); 
  84. } elseif ($details[$name][2] == "m") { 
  85. $this->client = new xmlrpc_client("https://" . $details[$name][1] . 
  86. ".mortgageprocrm.com/api/xmlrpc"); 
  87. } else { 
  88. throw new iSDKException("Invalid application name: \"" . $name . "\""); 
  89. } else { 
  90. throw new iSDKException("Application Does Not Exist: \"" . $name . "\""); 
  91. $this->key = $details[$name][3]; 
  92.  
  93. /** Return Raw PHP Types */ 
  94. $this->client->return_type = "phpvals"; 
  95.  
  96. /** SSL Certificate Verification */ 
  97. $this->client->setSSLVerifyPeer(TRUE); 
  98. $this->client->setCaCertificate((__DIR__ != '__DIR__' ? __DIR__ : dirname(__FILE__)) . '/infusionsoft.pem'); 
  99.  
  100. $carray = array( 
  101. php_xmlrpc_encode($this->key),  
  102. php_xmlrpc_encode($user),  
  103. php_xmlrpc_encode(md5($pass))); 
  104.  
  105. $this->key = $this->methodCaller("DataService.getTemporaryKey", $carray); 
  106.  
  107. $this->encKey = php_xmlrpc_encode($this->key); 
  108.  
  109. try { 
  110. $connected = $this->dsGetSetting("Application", "enabled"); 
  111. } catch (iSDKException $e) { 
  112. throw new iSDKException("Connection Failed"); 
  113. return TRUE; 
  114.  
  115. /** 
  116. * @method echo 
  117. * @description Worthless public function, used to validate a connection 
  118. * @param string $txt 
  119. * @return int|mixed|string 
  120. */ 
  121. public function appEcho($txt) 
  122. $carray = array( 
  123. php_xmlrpc_encode($txt)); 
  124.  
  125. return $this->methodCaller("DataService.echo", $carray); 
  126.  
  127. /** 
  128. * @method Method Caller 
  129. * @description Builds XML and Sends the Call 
  130. * @param string $service 
  131. * @param array $callArray 
  132. * @return int|mixed|string 
  133. * @throws iSDKException 
  134. */ 
  135. public function methodCaller($service, $callArray) 
  136. /** Set up the call */ 
  137. $call = new xmlrpcmsg($service, $callArray); 
  138.  
  139. if ($service != 'DataService.getTemporaryKey') { 
  140. array_unshift($call->params, $this->encKey); 
  141.  
  142. /** Send the call */ 
  143. $now = time(); 
  144. $start = microtime(); 
  145. $result = $this->client->send($call); 
  146.  
  147. $stop = microtime(); 
  148. /** Check the returned value to see if it was successful and return it */ 
  149. if (!$result->faultCode()) { 
  150. if ($this->loggingEnabled == 1) { 
  151. $this->log(array('Method' => $service, 'Call' => $callArray, 'Start' => $start, 'Stop' => $stop, 'Now' => $now, 'Result' => $result, 'Error' => 'No', 'ErrorCode' => 'No Error Code Received')); 
  152. return $result->value(); 
  153. } else { 
  154. if ($this->loggingEnabled == 1) { 
  155. $this->log(array('Method' => $service, 'Call' => $callArray, 'Start' => $start, 'Stop' => $stop, 'Now' => $now, 'Result' => $result, 'Error' => 'Yes', 'ErrorCode' => "ERROR: " . $result->faultCode() . " - " . $result->faultString())); 
  156. if ($this->debug == "kill") { 
  157. die("ERROR: " . $result->faultCode() . " - " . 
  158. $result->faultString()); 
  159. } elseif ($this->debug == "on") { 
  160. return "ERROR: " . $result->faultCode() . " - " . 
  161. $result->faultString(); 
  162. } elseif ($this->debug == "throw") { 
  163. throw new iSDKException($result->faultString(), $result->faultCode()); 
  164. } elseif ($this->debug == "off") { 
  165. //ignore! 
  166.  
  167.  
  168. /** 
  169. * @service Affiliate Program Service 
  170. */ 
  171.  
  172. /** 
  173. * @method getAffiliatesByProgram 
  174. * @description Gets a list of all of the affiliates with their contact data for the specified program. This includes all of the custom fields defined for the contact and affiliate records that are retrieved. 
  175. * @param int $programId 
  176. * @return array 
  177. */ 
  178. public function getAffiliatesByProgram($programId) 
  179. $carray = array( 
  180. php_xmlrpc_encode((int)$programId)); 
  181. return $this->methodCaller("AffiliateProgramService.getAffiliatesByProgram", $carray); 
  182.  
  183. /** 
  184. * @method getProgramsForAffiliate 
  185. * @description Gets a list of all of the Affiliate Programs for the Affiliate specified. 
  186. * @param int $affiliateId 
  187. * @return array 
  188. */ 
  189. public function getProgramsForAffiliate($affiliateId) 
  190. $carray = array( 
  191. php_xmlrpc_encode((int)$affiliateId)); 
  192. return $this->methodCaller("AffiliateProgramService.getProgramsForAffiliate", $carray); 
  193.  
  194. /** 
  195. * @method getAffiliatePrograms 
  196. * @description Gets a list of all of the Affiliate Programs that are in the application. 
  197. * @return int|mixed|string 
  198. */ 
  199. public function getAffiliatePrograms() 
  200. $carray = array(); 
  201. return $this->methodCaller("AffiliateProgramService.getAffiliatePrograms", $carray); 
  202.  
  203. /** 
  204. * @method getResourcesForAffiliateProgram 
  205. * @description Gets a list of all of the resources that are associated to the Affiliate Program specified. 
  206. * @param int $programId 
  207. * @return array 
  208. */ 
  209. public function getResourcesForAffiliateProgram($programId) 
  210. $carray = array( 
  211. php_xmlrpc_encode((int)$programId)); 
  212. return $this->methodCaller("AffiliateProgramService.getResourcesForAffiliateProgram", $carray); 
  213.  
  214. /** 
  215. * @service Affiliate Service 
  216. */ 
  217.  
  218. /** 
  219. * @method affClawbacks 
  220. * @description returns all clawbacks in a date range 
  221. * @param int $affId 
  222. * @param date $startDate 
  223. * @param date $endDate 
  224. * @return array 
  225. */ 
  226. public function affClawbacks($affId, $startDate, $endDate) 
  227. $carray = array( 
  228. php_xmlrpc_encode((int)$affId),  
  229. php_xmlrpc_encode($startDate, array('auto_dates')),  
  230. php_xmlrpc_encode($endDate, array('auto_dates'))); 
  231. return $this->methodCaller("APIAffiliateService.affClawbacks", $carray); 
  232.  
  233. /** 
  234. * @method affCommissions 
  235. * @description returns all commissions in a date range 
  236. * @param int $affId 
  237. * @param date $startDate 
  238. * @param date $endDate 
  239. * @return array 
  240. */ 
  241. public function affCommissions($affId, $startDate, $endDate) 
  242. $carray = array( 
  243. php_xmlrpc_encode((int)$affId),  
  244. php_xmlrpc_encode($startDate, array('auto_dates')),  
  245. php_xmlrpc_encode($endDate, array('auto_dates'))); 
  246. return $this->methodCaller("APIAffiliateService.affCommissions", $carray); 
  247.  
  248. /** 
  249. * @method affPayouts 
  250. * @description returns all affiliate payouts in a date range 
  251. * @param int $affId 
  252. * @param date $startDate 
  253. * @param date $endDate 
  254. * @return array 
  255. */ 
  256. public function affPayouts($affId, $startDate, $endDate) 
  257. $carray = array( 
  258. php_xmlrpc_encode((int)$affId),  
  259. php_xmlrpc_encode($startDate, array('auto_dates')),  
  260. php_xmlrpc_encode($endDate, array('auto_dates'))); 
  261. return $this->methodCaller("APIAffiliateService.affPayouts", $carray); 
  262.  
  263. /** 
  264. * @method affRunningTotals 
  265. * @description Returns a list with each row representing a single affiliates totals represented by a map with key (one of the names above, and value being the total for that variable) 
  266. * @param array $affList 
  267. * @return array 
  268. */ 
  269. public function affRunningTotals($affList) 
  270. $carray = array( 
  271. php_xmlrpc_encode($affList)); 
  272. return $this->methodCaller("APIAffiliateService.affRunningTotals", $carray); 
  273.  
  274. /** 
  275. * @method affSummary 
  276. * @description returns how much the specified affiliates are owed 
  277. * @param array $affList 
  278. * @param date $startDate 
  279. * @param date $endDate 
  280. * @return array 
  281. */ 
  282. public function affSummary($affList, $startDate, $endDate) 
  283. $carray = array( 
  284. php_xmlrpc_encode($affList),  
  285. php_xmlrpc_encode($startDate, array('auto_dates')),  
  286. php_xmlrpc_encode($endDate, array('auto_dates'))); 
  287. return $this->methodCaller("APIAffiliateService.affSummary", $carray); 
  288.  
  289. /** 
  290. * @method getRedirectLinksForAffiliate 
  291. * @description returns redirect links for affiliate specified 
  292. * @param $affiliateId 
  293. * @return int|mixed|string 
  294. */ 
  295. public function getRedirectLinksForAffiliate($affiliateId) 
  296. $carray = array( 
  297. php_xmlrpc_encode((int)$affiliateId)); 
  298. return $this->methodCaller("AffiliateService.getRedirectLinksForAffiliate", $carray); 
  299.  
  300. /** 
  301. * @service Contact Service 
  302. */ 
  303.  
  304. /** 
  305. * @method add 
  306. * @description add Contact to Infusionsoft (no duplicate checking) 
  307. * @param array $cMap 
  308. * @param string $optReason 
  309. * @return int 
  310. */ 
  311. public function addCon($cMap, $optReason = "") 
  312.  
  313. $carray = array( 
  314. php_xmlrpc_encode($cMap, array('auto_dates'))); 
  315.  
  316. $conID = $this->methodCaller("ContactService.add", $carray); 
  317. if (!empty($cMap['Email'])) { 
  318. if ($optReason == "") { 
  319. $this->optIn($cMap['Email']); 
  320. } else { 
  321. $this->optIn($cMap['Email'], $optReason); 
  322. return $conID; 
  323.  
  324. /** 
  325. * @method update 
  326. * @description Update an existing contact 
  327. * @param int $cid 
  328. * @param array $cMap 
  329. * @return int 
  330. */ 
  331. public function updateCon($cid, $cMap) 
  332.  
  333. $carray = array( 
  334. php_xmlrpc_encode((int)$cid),  
  335. php_xmlrpc_encode($cMap, array('auto_dates'))); 
  336. return $this->methodCaller("ContactService.update", $carray); 
  337.  
  338. /** 
  339. * @method merge 
  340. * @description Merge 2 contacts 
  341. * @param int $cid 
  342. * @param int $dcid 
  343. * @return int 
  344. */ 
  345. public function mergeCon($cid, $dcid) 
  346. $carray = array( 
  347. php_xmlrpc_encode($cid),  
  348. php_xmlrpc_encode($dcid)); 
  349.  
  350. return $this->methodCaller("ContactService.merge", $carray); 
  351.  
  352. /** 
  353. * @method findbyEmail 
  354. * @description finds all contact with an email address 
  355. * @param string $eml 
  356. * @param array $fMap 
  357. * @return array 
  358. */ 
  359. public function findByEmail($eml, $fMap) 
  360.  
  361. $carray = array( 
  362. php_xmlrpc_encode($eml),  
  363. php_xmlrpc_encode($fMap)); 
  364. return $this->methodCaller("ContactService.findByEmail", $carray); 
  365.  
  366. /** 
  367. * @method load 
  368. * @description Loads a contacts data 
  369. * @param int $cid 
  370. * @param array $rFields 
  371. * @return array 
  372. */ 
  373. public function loadCon($cid, $rFields) 
  374.  
  375. $carray = array( 
  376. php_xmlrpc_encode((int)$cid),  
  377. php_xmlrpc_encode($rFields)); 
  378. return $this->methodCaller("ContactService.load", $carray); 
  379.  
  380. /** 
  381. * @method addToGroup 
  382. * @description Apply a Tag to a Contact 
  383. * @param int $cid 
  384. * @param int $gid 
  385. * @return bool 
  386. */ 
  387. public function grpAssign($cid, $gid) 
  388. $carray = array( 
  389. php_xmlrpc_encode((int)$cid),  
  390. php_xmlrpc_encode((int)$gid)); 
  391. return $this->methodCaller("ContactService.addToGroup", $carray); 
  392.  
  393. /** 
  394. * @method removeFromGroup 
  395. * @description Remove a Tag from a Contact 
  396. * @param int $cid 
  397. * @param int $gid 
  398. * @return bool 
  399. */ 
  400. public function grpRemove($cid, $gid) 
  401. $carray = array( 
  402. php_xmlrpc_encode((int)$cid),  
  403. php_xmlrpc_encode((int)$gid)); 
  404. return $this->methodCaller("ContactService.removeFromGroup", $carray); 
  405.  
  406. /** 
  407. * @method resumeCampaignForContact 
  408. * @description resumes a legacy followup sequence a contact is in 
  409. * @param int $cid 
  410. * @param int $sequenceId 
  411. * @return bool 
  412. */ 
  413. public function resumeCampaignForContact($cid, $sequenceId) 
  414. $carray = array( 
  415. php_xmlrpc_encode((int)$cid),  
  416. php_xmlrpc_encode((int)$sequenceId)); 
  417. return $this->methodCaller("ContactService.resumeCampaignForContact", $carray); 
  418.  
  419. /** 
  420. * @method addToCampaign 
  421. * @description adds a contact to a legacy followup sequence 
  422. * @param int $cid 
  423. * @param int $campId 
  424. * @return bool 
  425. */ 
  426. public function campAssign($cid, $campId) 
  427. $carray = array( 
  428. php_xmlrpc_encode((int)$cid),  
  429. php_xmlrpc_encode((int)$campId)); 
  430. return $this->methodCaller("ContactService.addToCampaign", $carray); 
  431.  
  432. /** 
  433. * @method getNextCampaignStep 
  434. * @description gets next step in a legacy followup sequence 
  435. * @param int $cid 
  436. * @param int $campId 
  437. * @return array 
  438. */ 
  439. public function getNextCampaignStep($cid, $campId) 
  440. $carray = array( 
  441. php_xmlrpc_encode((int)$cid),  
  442. php_xmlrpc_encode((int)$campId)); 
  443. return 
  444. $this->methodCaller("ContactService.getNextCampaignStep", $carray); 
  445.  
  446. /** 
  447. * @method getCampaigneeStepDetails 
  448. * @description get step details for a legacy followup sequence 
  449. * @param int $cid 
  450. * @param int $stepId 
  451. * @return array 
  452. */ 
  453. public function getCampaigneeStepDetails($cid, $stepId) 
  454. $carray = array( 
  455. php_xmlrpc_encode((int)$cid),  
  456. php_xmlrpc_encode((int)$stepId)); 
  457. return 
  458. $this->methodCaller("ContactService.getCampaigneeStepDetails", $carray); 
  459.  
  460. /** 
  461. * @method rescheduleCampaignStep 
  462. * @description reschedule a legacy followup sequence 
  463. * @param array $cidList 
  464. * @param int $campId 
  465. * @return int 
  466. */ 
  467. public function rescheduleCampaignStep($cidList, $campId) 
  468. $carray = array( 
  469. php_xmlrpc_encode($cidList),  
  470. php_xmlrpc_encode((int)$campId)); 
  471. return 
  472. $this->methodCaller("ContactService.rescheduleCampaignStep", $carray); 
  473.  
  474. /** 
  475. * @method removeFromCampaign 
  476. * @description remove a contact from a legacy followup sequence 
  477. * @param int $cid 
  478. * @param int $campId 
  479. * @return bool 
  480. */ 
  481. public function campRemove($cid, $campId) 
  482. $carray = array( 
  483. php_xmlrpc_encode((int)$cid),  
  484. php_xmlrpc_encode((int)$campId)); 
  485. return $this->methodCaller("ContactService.removeFromCampaign", $carray); 
  486.  
  487. /** 
  488. * @method pauseCampaign 
  489. * @description pause a legacy followup sequence for a contact 
  490. * @param int $cid 
  491. * @param int $campId 
  492. * @return bool 
  493. */ 
  494. public function campPause($cid, $campId) 
  495. $carray = array( 
  496. php_xmlrpc_encode((int)$cid),  
  497. php_xmlrpc_encode((int)$campId)); 
  498. return $this->methodCaller("ContactService.pauseCampaign", $carray); 
  499.  
  500. /** 
  501. * @method runActionSequence 
  502. * @description run an actionset on a contact 
  503. * @param int $cid 
  504. * @param int $aid 
  505. * @return array 
  506. */ 
  507. public function runAS($cid, $aid) 
  508. $carray = array( 
  509. php_xmlrpc_encode((int)$cid),  
  510. php_xmlrpc_encode((int)$aid)); 
  511. return $this->methodCaller("ContactService.runActionSequence", $carray); 
  512.  
  513. /** 
  514. * @method applyActivityHistoryTemplate 
  515. * @description add a note, task, or appointment to a contact from a template 
  516. * @param int $contactId 
  517. * @param int $historyId 
  518. * @param int $userId 
  519. * @return int|mixed|string 
  520. */ 
  521. public function applyActivityHistoryTemplate($contactId, $historyId, $userId) 
  522. $carray = array( 
  523. php_xmlrpc_encode((int)$contactId),  
  524. php_xmlrpc_encode((int)$historyId),  
  525. php_xmlrpc_encode((int)$userId)); 
  526. return $this->methodCaller("ContactService.applyActivityHistoryTemplate", $carray); 
  527.  
  528. /** 
  529. * @method getActivityHistoryTemplateMap 
  530. * @description get templates for use with applyActivityHistoryTemplate 
  531. * @return array 
  532. */ 
  533. public function getActivityHistoryTemplateMap() 
  534. $carray = array(); 
  535. return $this->methodCaller("ContactService.getActivityHistoryTemplateMap", $carray); 
  536.  
  537. /** 
  538. * @method addWithDupCheck 
  539. * @description add a contact with duplicate checking 
  540. * @param array $cMap 
  541. * @param string $checkType - 'Email', 'EmailAndName', or 'EmailAndNameAnd Company' 
  542. * @return int 
  543. */ 
  544. public function addWithDupCheck($cMap, $checkType) 
  545. $carray = array( 
  546. php_xmlrpc_encode($cMap, array('auto_dates')),  
  547. php_xmlrpc_encode($checkType)); 
  548. return $this->methodCaller("ContactService.addWithDupCheck", $carray); 
  549.  
  550. /** 
  551. * @service Credit Card Submission Service 
  552. */ 
  553.  
  554. /** 
  555. * @method requestSubmissionToken 
  556. * @description gets a token, which is needed to POST a credit card to the application 
  557. * @param int $contactId 
  558. * @param string $successUrl 
  559. * @param string $failureUrl 
  560. * @return string 
  561. */ 
  562. public function requestCcSubmissionToken($contactId, $successUrl, $failureUrl) 
  563. $carray = array( 
  564. php_xmlrpc_encode((int)$contactId),  
  565. php_xmlrpc_encode((string)$successUrl),  
  566. php_xmlrpc_encode((string)$failureUrl)); 
  567. return $this->methodCaller("CreditCardSubmissionService.requestSubmissionToken", $carray); 
  568.  
  569. /** 
  570. * @method requestCreditCardId 
  571. * @description retrieves credit card details (CC number not included) that have been posted to the app 
  572. * @param $token 
  573. * @return array 
  574. */ 
  575. public function requestCreditCardId($token) 
  576. $carray = array( 
  577. php_xmlrpc_encode($token)); 
  578. return $this->methodCaller("CreditCardSubmissionService.requestCreditCardId", $carray); 
  579.  
  580. /** 
  581. * @service Data Service 
  582. */ 
  583.  
  584. /** 
  585. * @method getAppSetting 
  586. * @description gets an app setting 
  587. * @param string $module 
  588. * @param string $setting 
  589. * @return int|mixed|string 
  590. */ 
  591. public function dsGetSetting($module, $setting) 
  592. $carray = array( 
  593. php_xmlrpc_encode($module),  
  594. php_xmlrpc_encode($setting)); 
  595. return $this->methodCaller("DataService.getAppSetting", $carray); 
  596.  
  597. /** 
  598. * @method add 
  599. * @description Add a record to a table 
  600. * @param string $tName 
  601. * @param array $iMap 
  602. * @return int 
  603. */ 
  604. public function dsAdd($tName, $iMap) 
  605. $carray = array( 
  606. php_xmlrpc_encode($tName),  
  607. php_xmlrpc_encode($iMap, array('auto_dates'))); 
  608.  
  609. return $this->methodCaller("DataService.add", $carray); 
  610.  
  611. /** 
  612. * @method dsAddWithImage 
  613. * @description Add a record to a table that includes an image 
  614. * @param string $tName 
  615. * @param array $iMap 
  616. * @return int 
  617. */ 
  618. public function dsAddWithImage($tName, $iMap) 
  619. $carray = array( 
  620. php_xmlrpc_encode($tName),  
  621. php_xmlrpc_encode($iMap, array('auto_dates', 'auto_base64'))); 
  622.  
  623. return $this->methodCaller("DataService.add", $carray); 
  624.  
  625. /** 
  626. * @method delete 
  627. * @description delete a record from Infusionsoft 
  628. * @param string $tName 
  629. * @param int $id 
  630. * @return bool 
  631. */ 
  632. public function dsDelete($tName, $id) 
  633. $carray = array( 
  634. php_xmlrpc_encode($tName),  
  635. php_xmlrpc_encode((int)$id)); 
  636.  
  637. return $this->methodCaller("DataService.delete", $carray); 
  638.  
  639. /** 
  640. * @method update 
  641. * @description Update a record in any table 
  642. * @param string $tName 
  643. * @param int $id 
  644. * @param array $iMap 
  645. * @return int 
  646. */ 
  647. public function dsUpdate($tName, $id, $iMap) 
  648. $carray = array( 
  649. php_xmlrpc_encode($tName),  
  650. php_xmlrpc_encode((int)$id),  
  651. php_xmlrpc_encode($iMap, array('auto_dates'))); 
  652.  
  653. return $this->methodCaller("DataService.update", $carray); 
  654.  
  655. /** 
  656. * @method dsUpdateWithImage 
  657. * @description Update a record in any table with an image 
  658. * @param string $tName 
  659. * @param int $id 
  660. * @param array $iMap 
  661. * @return int 
  662. */ 
  663. public function dsUpdateWithImage($tName, $id, $iMap) 
  664. $carray = array( 
  665. php_xmlrpc_encode($tName),  
  666. php_xmlrpc_encode((int)$id),  
  667. php_xmlrpc_encode($iMap, array('auto_dates', 'auto_base64'))); 
  668.  
  669. return $this->methodCaller("DataService.update", $carray); 
  670.  
  671. /** 
  672. * @method load 
  673. * @description Load a record from any table 
  674. * @param string $tName 
  675. * @param int $id 
  676. * @param array $rFields 
  677. * @return array 
  678. */ 
  679. public function dsLoad($tName, $id, $rFields) 
  680. $carray = array( 
  681. php_xmlrpc_encode($tName),  
  682. php_xmlrpc_encode((int)$id),  
  683. php_xmlrpc_encode($rFields)); 
  684.  
  685. return $this->methodCaller("DataService.load", $carray); 
  686.  
  687. /** 
  688. * @method findByField 
  689. * @description finds records by searching a specific field 
  690. * @param string $tName 
  691. * @param int $limit 
  692. * @param int $page 
  693. * @param string $field 
  694. * @param string $value 
  695. * @param array $rFields 
  696. * @return array 
  697. */ 
  698. public function dsFind($tName, $limit, $page, $field, $value, $rFields) 
  699. $carray = array( 
  700. php_xmlrpc_encode($tName),  
  701. php_xmlrpc_encode((int)$limit),  
  702. php_xmlrpc_encode((int)$page),  
  703. php_xmlrpc_encode($field),  
  704. php_xmlrpc_encode($value),  
  705. php_xmlrpc_encode($rFields)); 
  706.  
  707. return $this->methodCaller("DataService.findByField", $carray); 
  708.  
  709. /** 
  710. * @method query 
  711. * @description Finds records based on query 
  712. * @param string $tName 
  713. * @param int $limit 
  714. * @param int $page 
  715. * @param array $query 
  716. * @param array $rFields 
  717. * @return array 
  718. */ 
  719. public function dsQuery($tName, $limit, $page, $query, $rFields) 
  720. $carray = array( 
  721. php_xmlrpc_encode($tName),  
  722. php_xmlrpc_encode((int)$limit),  
  723. php_xmlrpc_encode((int)$page),  
  724. php_xmlrpc_encode($query, array('auto_dates')),  
  725. php_xmlrpc_encode($rFields)); 
  726.  
  727. return $this->methodCaller("DataService.query", $carray); 
  728.  
  729. /** 
  730. * @method queryWithOrderBy 
  731. * @description Finds records based on query with option to sort 
  732. * @param string $tName 
  733. * @param int $limit 
  734. * @param int $page 
  735. * @param array $query 
  736. * @param array $rFields 
  737. * @param string $orderByField 
  738. * @param bool $ascending 
  739. * @return array 
  740. */ 
  741. public function dsQueryOrderBy($tName, $limit, $page, $query, $rFields, $orderByField, $ascending = TRUE) 
  742. $carray = array( 
  743. php_xmlrpc_encode($tName),  
  744. php_xmlrpc_encode((int)$limit),  
  745. php_xmlrpc_encode((int)$page),  
  746. php_xmlrpc_encode($query, array('auto_dates')),  
  747. php_xmlrpc_encode($rFields),  
  748. php_xmlrpc_encode($orderByField),  
  749. php_xmlrpc_encode((bool)$ascending)); 
  750.  
  751. return $this->methodCaller("DataService.query", $carray); 
  752.  
  753. /** 
  754. * @method DataService.Count 
  755. * @description Gets record count based on query 
  756. * @param string $tName 
  757. * @param array $query 
  758. * @return int 
  759. */ 
  760.  
  761. public function dsCount($tName, $query) 
  762. $carray = array( 
  763. php_xmlrpc_encode($tName),  
  764. php_xmlrpc_encode($query, array('auto_dates')) 
  765. ); 
  766. return $this->methodCaller("DataService.count", $carray); 
  767.  
  768. /** 
  769. * @method addCustomField 
  770. * @description adds a custom field 
  771. * @param string $context 
  772. * @param string $displayName 
  773. * @param int $dataType 
  774. * @param int $headerID 
  775. * @return int 
  776. */ 
  777. public function addCustomField($context, $displayName, $dataType, $headerID) 
  778. $carray = array( 
  779.  
  780. php_xmlrpc_encode($context),  
  781. php_xmlrpc_encode($displayName),  
  782. php_xmlrpc_encode($dataType),  
  783. php_xmlrpc_encode((int)$headerID)); 
  784.  
  785. return $this->methodCaller("DataService.addCustomField", $carray); 
  786.  
  787. /** 
  788. * @method authenticateUser 
  789. * @description Authenticates a user account in Infusionsoft 
  790. * @param string $userName 
  791. * @param string $password 
  792. * @return int 
  793. */ 
  794. public function authenticateUser($userName, $password) 
  795. $password = strtolower(md5($password)); 
  796. $carray = array( 
  797. php_xmlrpc_encode($userName),  
  798. php_xmlrpc_encode($password)); 
  799.  
  800. return $this->methodCaller("DataService.authenticateUser", $carray); 
  801.  
  802. /** 
  803. * @method - updateCustomField 
  804. * @description update a custom field 
  805. * @param int $fieldId 
  806. * @param array $fieldValues 
  807. * @return int 
  808. */ 
  809. public function updateCustomField($fieldId, $fieldValues) 
  810. $carray = array( 
  811. php_xmlrpc_encode((int)$fieldId),  
  812. php_xmlrpc_encode($fieldValues)); 
  813. return $this->methodCaller("DataService.updateCustomField", $carray); 
  814.  
  815. /** 
  816. * @service Discount Service 
  817. */ 
  818.  
  819. /** 
  820. * @method addFreeTrial 
  821. * @description creates a subscription free trial for the shopping cart 
  822. * @param string $name 
  823. * @param string $description 
  824. * @param int $freeTrialDays 
  825. * @param int $hidePrice 
  826. * @param int $subscriptionPlanId 
  827. * @return int 
  828. */ 
  829. public function addFreeTrial($name, $description, $freeTrialDays, $hidePrice, $subscriptionPlanId) 
  830. $carray = array( 
  831. php_xmlrpc_encode((string)$name),  
  832. php_xmlrpc_encode((string)$description),  
  833. php_xmlrpc_encode((int)$freeTrialDays),  
  834. php_xmlrpc_encode((int)$hidePrice),  
  835. php_xmlrpc_encode((int)$subscriptionPlanId)); 
  836. return $this->methodCaller("DiscountService.addFreeTrial", $carray); 
  837.  
  838. /** 
  839. * @method getFreeTrial 
  840. * @description retrieves the details on the given free trial 
  841. * @param int $trialId 
  842. * @return array 
  843. */ 
  844. public function getFreeTrial($trialId) 
  845. $carray = array( 
  846. php_xmlrpc_encode((int)$trialId)); 
  847. return $this->methodCaller("DiscountService.getFreeTrial", $carray); 
  848.  
  849. /** 
  850. * @method addOrderTotalDiscount 
  851. * @description creates an order total discount for the shopping cart 
  852. * @param string $name 
  853. * @param string $description 
  854. * @param int $applyDiscountToCommission 
  855. * @param int $percentOrAmt 
  856. * @paramOption 0 Amount 
  857. * @paramOption 1 Percent 
  858. * @param double $amt 
  859. * @param string $payType 
  860. * @paramOption Gross 
  861. * @paramOption Net 
  862. * @return int 
  863. */ 
  864. public function addOrderTotalDiscount($name, $description, $applyDiscountToCommission, $percentOrAmt, $amt, $payType) 
  865. $carray = array( 
  866. php_xmlrpc_encode((string)$name),  
  867. php_xmlrpc_encode((string)$description),  
  868. php_xmlrpc_encode((int)$applyDiscountToCommission),  
  869. php_xmlrpc_encode((int)$percentOrAmt),  
  870. php_xmlrpc_encode($amt),  
  871. php_xmlrpc_encode($payType)); 
  872. return $this->methodCaller("DiscountService.addOrderTotalDiscount", $carray); 
  873.  
  874. /** 
  875. * @method getOrderTotalDiscount 
  876. * @description retrieves the details on the given order total discount 
  877. * @param int $id 
  878. * @return array 
  879. */ 
  880. public function getOrderTotalDiscount($id) 
  881. $carray = array( 
  882. php_xmlrpc_encode((int)$id)); 
  883. return $this->methodCaller("DiscountService.getOrderTotalDiscount", $carray); 
  884.  
  885. /** 
  886. * @method addCategoryDiscount 
  887. * @description creates a product category discount for the shopping cart 
  888. * @param string $name 
  889. * @param string $description 
  890. * @param int $applyDiscountToCommission 
  891. * @param double $amt 
  892. * @return int 
  893. */ 
  894. public function addCategoryDiscount($name, $description, $applyDiscountToCommission, $amt) 
  895. $carray = array( 
  896. php_xmlrpc_encode((string)$name),  
  897. php_xmlrpc_encode((string)$description),  
  898. php_xmlrpc_encode((int)$applyDiscountToCommission),  
  899. php_xmlrpc_encode($amt)); 
  900. return $this->methodCaller("DiscountService.addCategoryDiscount", $carray); 
  901.  
  902. /** 
  903. * @method getCategoryDiscount 
  904. * @description retrieves the details on the Category discount 
  905. * @param int $id 
  906. * @return array 
  907. */ 
  908. public function getCategoryDiscount($id) 
  909. $carray = array( 
  910. php_xmlrpc_encode((int)$id)); 
  911. return $this->methodCaller("DiscountService.getCategoryDiscount", $carray); 
  912.  
  913. /** 
  914. * @method addCategoryAssignmentToCategoryDiscount 
  915. * @description assigns a product category to a particular category discount 
  916. * @param int $categoryDiscountId 
  917. * @param int $productCategoryId 
  918. * @return int 
  919. */ 
  920. public function addCategoryAssignmentToCategoryDiscount($categoryDiscountId, $productCategoryId) 
  921. $carray = array( 
  922. php_xmlrpc_encode((int)$categoryDiscountId),  
  923. php_xmlrpc_encode((int)$productCategoryId)); 
  924. return $this->methodCaller("DiscountService.addCategoryAssignmentToCategoryDiscount", $carray); 
  925.  
  926. /** 
  927. * @method getCategoryAssignmentsForCategoryDiscount 
  928. * @description retrieves the product categories that are currently set for the given category discount 
  929. * @param int $id 
  930. * @return array 
  931. */ 
  932. public function getCategoryAssignmentsForCategoryDiscount($id) 
  933. $carray = array( 
  934. php_xmlrpc_encode((int)$id)); 
  935. return $this->methodCaller("DiscountService.getCategoryAssignmentsForCategoryDiscount", $carray); 
  936.  
  937. /** 
  938. * @method addProductTotalDiscount 
  939. * @description creates a product total discount for the shopping cart 
  940. * @param string $name 
  941. * @param string $description 
  942. * @param int $applyDiscountToCommission 
  943. * @param int $productId 
  944. * @param int $percentOrAmt 
  945. * @paramOption 0 Amount 
  946. * @paramOption 1 Percent 
  947. * @param double $amt 
  948. * @return int 
  949. */ 
  950. public function addProductTotalDiscount($name, $description, $applyDiscountToCommission, $productId, $percentOrAmt, $amt) 
  951. $carray = array( 
  952. php_xmlrpc_encode((string)$name),  
  953. php_xmlrpc_encode((string)$description),  
  954. php_xmlrpc_encode((int)$applyDiscountToCommission),  
  955. php_xmlrpc_encode((int)$productId),  
  956. php_xmlrpc_encode((int)$percentOrAmt),  
  957. php_xmlrpc_encode($amt)); 
  958. return $this->methodCaller("DiscountService.addProductTotalDiscount", $carray); 
  959.  
  960. /** 
  961. * @method getProductTotalDiscount 
  962. * @description retrieves the details on the given product total discount 
  963. * @param int $id 
  964. * @return array 
  965. */ 
  966. public function getProductTotalDiscount($id) 
  967. $carray = array( 
  968. php_xmlrpc_encode((int)$id)); 
  969. return $this->methodCaller("DiscountService.getProductTotalDiscount", $carray); 
  970.  
  971. /** 
  972. * @method addShippingTotalDiscount 
  973. * @description creates a shipping total discount for the shopping cart 
  974. * @param string $name 
  975. * @param string $description 
  976. * @param int $applyDiscountToCommission 
  977. * @param int $percentOrAmt 
  978. * @paramOption 0 Amount 
  979. * @paramOption 1 Percent 
  980. * @param double $amt 
  981. * @return int 
  982. */ 
  983. public function addShippingTotalDiscount($name, $description, $applyDiscountToCommission, $percentOrAmt, $amt) 
  984. $carray = array( 
  985. php_xmlrpc_encode((string)$name),  
  986. php_xmlrpc_encode((string)$description),  
  987. php_xmlrpc_encode((int)$applyDiscountToCommission),  
  988. php_xmlrpc_encode((int)$percentOrAmt),  
  989. php_xmlrpc_encode($amt)); 
  990. return $this->methodCaller("DiscountService.addShippingTotalDiscount", $carray); 
  991.  
  992. /** 
  993. * @method getShippingTotalDiscount 
  994. * @description retrieves the details on the given shipping total discount 
  995. * @param int $id 
  996. * @return array 
  997. */ 
  998. public function getShippingTotalDiscount($id) 
  999. $carray = array( 
  1000. php_xmlrpc_encode((int)$id)); 
  1001. return $this->methodCaller("DiscountService.getShippingTotalDiscount", $carray); 
  1002.  
  1003. /** 
  1004. * @service API Email Service 
  1005. */ 
  1006.  
  1007. /** 
  1008. * @method attachEmail 
  1009. * @description attachs an email to a contacts email history 
  1010. * @param int $cId 
  1011. * @param string $fromName 
  1012. * @param string $fromAddress 
  1013. * @param string $toAddress 
  1014. * @param string $ccAddresses 
  1015. * @param string $bccAddresses 
  1016. * @param string $contentType 
  1017. * @param string $subject 
  1018. * @param string $htmlBody 
  1019. * @param string $txtBody 
  1020. * @param string $header 
  1021. * @param date $strRecvdDate 
  1022. * @param date $strSentDate 
  1023. * @param int $emailSentType 
  1024. * @return bool 
  1025. */ 
  1026. public function attachEmail($cId, $fromName, $fromAddress, $toAddress, $ccAddresses,  
  1027. $bccAddresses, $contentType, $subject, $htmlBody, $txtBody,  
  1028. $header, $strRecvdDate, $strSentDate, $emailSentType = 1) 
  1029. $carray = array( 
  1030. php_xmlrpc_encode((int)$cId),  
  1031. php_xmlrpc_encode($fromName),  
  1032. php_xmlrpc_encode($fromAddress),  
  1033. php_xmlrpc_encode($toAddress),  
  1034. php_xmlrpc_encode($ccAddresses),  
  1035. php_xmlrpc_encode($bccAddresses),  
  1036. php_xmlrpc_encode($contentType),  
  1037. php_xmlrpc_encode($subject),  
  1038. php_xmlrpc_encode($htmlBody),  
  1039. php_xmlrpc_encode($txtBody),  
  1040. php_xmlrpc_encode($header),  
  1041. php_xmlrpc_encode($strRecvdDate),  
  1042. php_xmlrpc_encode($strSentDate),  
  1043. php_xmlrpc_encode($emailSentType)); 
  1044. return $this->methodCaller("APIEmailService.attachEmail", $carray); 
  1045.  
  1046. /** 
  1047. * @method getAvailableMergeFields 
  1048. * @description gets a list of all available merge fields 
  1049. * @param string $mergeContext 
  1050. * @return array 
  1051. */ 
  1052. public function getAvailableMergeFields($mergeContext) 
  1053. $carray = array( 
  1054. php_xmlrpc_encode($mergeContext)); 
  1055. return $this->methodCaller("APIEmailService.getAvailableMergeFields", $carray); 
  1056.  
  1057. /** 
  1058. * @method sendEmail 
  1059. * @description send an email to a list of contacts 
  1060. * @param array $conList 
  1061. * @param string $fromAddress 
  1062. * @param string $toAddress 
  1063. * @param string $ccAddresses 
  1064. * @param string $bccAddresses 
  1065. * @param string $contentType 
  1066. * @param string $subject 
  1067. * @param string $htmlBody 
  1068. * @param string $txtBody 
  1069. * @return bool 
  1070. */ 
  1071. public function sendEmail($conList, $fromAddress, $toAddress, $ccAddresses, $bccAddresses, $contentType, $subject, $htmlBody, $txtBody) 
  1072. $carray = array( 
  1073. php_xmlrpc_encode($conList),  
  1074. php_xmlrpc_encode($fromAddress),  
  1075. php_xmlrpc_encode($toAddress),  
  1076. php_xmlrpc_encode($ccAddresses),  
  1077. php_xmlrpc_encode($bccAddresses),  
  1078. php_xmlrpc_encode($contentType),  
  1079. php_xmlrpc_encode($subject),  
  1080. php_xmlrpc_encode($htmlBody),  
  1081. php_xmlrpc_encode($txtBody)); 
  1082.  
  1083. return $this->methodCaller("APIEmailService.sendEmail", $carray); 
  1084.  
  1085. /** 
  1086. * @method sendTemplate 
  1087. * @description sends a template to a list of contacts 
  1088. * @note uses APIEmailService.sendEmail with different parameters 
  1089. * @param array $conList 
  1090. * @param int $template 
  1091. * @return bool 
  1092. */ 
  1093. public function sendTemplate($conList, $template) 
  1094. $carray = array( 
  1095. php_xmlrpc_encode($conList),  
  1096. php_xmlrpc_encode($template)); 
  1097. return $this->methodCaller("APIEmailService.sendEmail", $carray); 
  1098.  
  1099. /** 
  1100. * @note THIS IS DEPRECATED - USE addEmailTemplate instead! 
  1101. * @method createEmailTemplate 
  1102. * @description Creates a legacy Email Template 
  1103. * @param string $title 
  1104. * @param int $userID 
  1105. * @param string $fromAddress 
  1106. * @param string $toAddress 
  1107. * @param string $ccAddresses 
  1108. * @param string $bccAddresses 
  1109. * @param string $contentType 
  1110. * @param string $subject 
  1111. * @param string $htmlBody 
  1112. * @param string $txtBody 
  1113. * @return int 
  1114. */ 
  1115. public function createEmailTemplate($title, $userID, $fromAddress, $toAddress, $ccAddresses, $bccAddresses, $contentType, $subject, $htmlBody,  
  1116. $txtBody) 
  1117. $carray = array( 
  1118. php_xmlrpc_encode($title),  
  1119. php_xmlrpc_encode($category = ''),  
  1120. php_xmlrpc_encode($fromAddress),  
  1121. php_xmlrpc_encode($toAddress),  
  1122. php_xmlrpc_encode($ccAddresses),  
  1123. php_xmlrpc_encode($bccAddresses),  
  1124. php_xmlrpc_encode($subject),  
  1125. php_xmlrpc_encode($txtBody),  
  1126. php_xmlrpc_encode($htmlBody),  
  1127. php_xmlrpc_encode($contentType),  
  1128. php_xmlrpc_encode($mergeContext = 'Contact')); 
  1129. return $this->methodCaller("APIEmailService.addEmailTemplate", $carray); 
  1130.  
  1131. /** 
  1132. * @method addEmailTemplate 
  1133. * @description creates an Email Template 
  1134. * @param string $title 
  1135. * @param string $category 
  1136. * @param string $fromAddress 
  1137. * @param string $toAddress 
  1138. * @param string $ccAddresses 
  1139. * @param string $bccAddresses 
  1140. * @param string $subject 
  1141. * @param string $txtBody 
  1142. * @param string $htmlBody 
  1143. * @param string $contentType 
  1144. * @param string $mergeContext 
  1145. * @return int 
  1146. */ 
  1147. public function addEmailTemplate($title, $category, $fromAddress, $toAddress, $ccAddresses, $bccAddresses, $subject, $txtBody, $htmlBody, $contentType, $mergeContext) 
  1148. $carray = array( 
  1149. php_xmlrpc_encode($title),  
  1150. php_xmlrpc_encode($category),  
  1151. php_xmlrpc_encode($fromAddress),  
  1152. php_xmlrpc_encode($toAddress),  
  1153. php_xmlrpc_encode($ccAddresses),  
  1154. php_xmlrpc_encode($bccAddresses),  
  1155. php_xmlrpc_encode($subject),  
  1156. php_xmlrpc_encode($txtBody),  
  1157. php_xmlrpc_encode($htmlBody),  
  1158. php_xmlrpc_encode($contentType),  
  1159. php_xmlrpc_encode($mergeContext)); 
  1160. return $this->methodCaller("APIEmailService.addEmailTemplate", $carray); 
  1161.  
  1162. /** 
  1163. * @method getEmailTemplate 
  1164. * @description get the HTML of an email template 
  1165. * @param int $templateId 
  1166. * @return array 
  1167. */ 
  1168. public function getEmailTemplate($templateId) 
  1169. $carray = array( 
  1170. php_xmlrpc_encode((int)$templateId)); 
  1171. return $this->methodCaller("APIEmailService.getEmailTemplate", $carray); 
  1172.  
  1173. /** 
  1174. * @method updateEmailTemplate 
  1175. * @description Update an Email template 
  1176. * @param int $templateID 
  1177. * @param string $title 
  1178. * @param string $categories 
  1179. * @param string $fromAddress 
  1180. * @param string $toAddress 
  1181. * @param string $ccAddress 
  1182. * @param string $bccAddress 
  1183. * @param string $subject 
  1184. * @param string $textBody 
  1185. * @param string $htmlBody 
  1186. * @param string $contentType 
  1187. * @param string $mergeContext 
  1188. * @return bool 
  1189. */ 
  1190. public function updateEmailTemplate($templateID, $title, $categories, $fromAddress, $toAddress, $ccAddress, $bccAddress, $subject, $textBody, $htmlBody, $contentType, $mergeContext) 
  1191. $carray = array( 
  1192. php_xmlrpc_encode((int)$templateID),  
  1193. php_xmlrpc_encode($title),  
  1194. php_xmlrpc_encode($categories),  
  1195. php_xmlrpc_encode($fromAddress),  
  1196. php_xmlrpc_encode($toAddress),  
  1197. php_xmlrpc_encode($ccAddress),  
  1198. php_xmlrpc_encode($bccAddress),  
  1199. php_xmlrpc_encode($subject),  
  1200. php_xmlrpc_encode($textBody),  
  1201. php_xmlrpc_encode($htmlBody),  
  1202. php_xmlrpc_encode($contentType),  
  1203. php_xmlrpc_encode($mergeContext)); 
  1204. return $this->methodCaller("APIEmailService.updateEmailTemplate", $carray); 
  1205.  
  1206. /** 
  1207. * @method getOptStatus 
  1208. * @description get the Opt status of an email 
  1209. * @param string $email 
  1210. * @return int 
  1211. */ 
  1212. public function optStatus($email) 
  1213. $carray = array( 
  1214. php_xmlrpc_encode($email)); 
  1215. return $this->methodCaller("APIEmailService.getOptStatus", $carray); 
  1216.  
  1217. /** 
  1218. * @method optIn 
  1219. * @description Opts an email in to allow emails to be sent to them 
  1220. * @note Opt-In will only work on "non-marketable contacts not opted out people 
  1221. * @param string $email 
  1222. * @param string $reason 
  1223. * @return bool 
  1224. */ 
  1225. public function optIn($email, $reason = 'Contact Was Opted In through the API') 
  1226. $carray = array( 
  1227. php_xmlrpc_encode($email),  
  1228. php_xmlrpc_encode($reason)); 
  1229. return $this->methodCaller("APIEmailService.optIn", $carray); 
  1230.  
  1231. /** 
  1232. * @method optOut 
  1233. * @description Opts an email out. Emails will not be sent to them anymore 
  1234. * @param string $email 
  1235. * @param string $reason 
  1236. * @return bool 
  1237. */ 
  1238. public function optOut($email, $reason = 'Contact Was Opted Out through the API') 
  1239. $carray = array( 
  1240. php_xmlrpc_encode($email),  
  1241. php_xmlrpc_encode($reason)); 
  1242. return $this->methodCaller("APIEmailService.optOut", $carray); 
  1243.  
  1244. /** 
  1245. * @service File Service 
  1246. */ 
  1247.  
  1248. /** 
  1249. * @method getFile 
  1250. * @description Gets File 
  1251. * @param int $fileID 
  1252. * @return base64 encoded file data 
  1253. */ 
  1254. public function getFile($fileID) 
  1255.  
  1256. $carray = array( 
  1257. php_xmlrpc_encode((int)$fileID)); 
  1258. $result = $this->methodCaller("FileService.getFile", $carray); 
  1259. return $result; 
  1260.  
  1261. /** 
  1262. * @method uploadFile 
  1263. * @description Upload a file to Infusionsoft 
  1264. * @param string $fileName 
  1265. * @param string $base64Enc 
  1266. * @param int $cid 
  1267. * @return int|mixed|string 
  1268. */ 
  1269. public function uploadFile($fileName, $base64Enc, $cid = 0) 
  1270. $result = 0; 
  1271. if ($cid == 0) { 
  1272. $carray = array( 
  1273. php_xmlrpc_encode($fileName),  
  1274. php_xmlrpc_encode($base64Enc)); 
  1275. $result = $this->methodCaller("FileService.uploadFile", $carray); 
  1276. } else { 
  1277. $carray = array( 
  1278. php_xmlrpc_encode((int)$cid),  
  1279. php_xmlrpc_encode($fileName),  
  1280. php_xmlrpc_encode($base64Enc)); 
  1281. $result = $this->methodCaller("FileService.uploadFile", $carray); 
  1282. return $result; 
  1283.  
  1284. /** 
  1285. * @method replaceFile 
  1286. * @description replaces existing file 
  1287. * @param int $fileID 
  1288. * @param string $base64Enc 
  1289. * @return bool 
  1290. */ 
  1291. public function replaceFile($fileID, $base64Enc) 
  1292. $carray = array( 
  1293. php_xmlrpc_encode((int)$fileID),  
  1294. php_xmlrpc_encode($base64Enc)); 
  1295. $result = $this->methodCaller("FileService.replaceFile", $carray); 
  1296. return $result; 
  1297.  
  1298. /** 
  1299. * @method renameFile 
  1300. * @description rename existing file 
  1301. * @param int $fileID 
  1302. * @param string $fileName 
  1303. * @return bool 
  1304. */ 
  1305. public function renameFile($fileID, $fileName) 
  1306. $carray = array( 
  1307. php_xmlrpc_encode((int)$fileID),  
  1308. php_xmlrpc_encode($fileName)); 
  1309. $result = $this->methodCaller("FileService.renameFile", $carray); 
  1310. return $result; 
  1311.  
  1312. /** 
  1313. * @method getDownloadUrl 
  1314. * @description gets download url for public files 
  1315. * @param int $fileID 
  1316. * @return string 
  1317. */ 
  1318. public function getDownloadUrl($fileID) 
  1319. $carray = array( 
  1320. php_xmlrpc_encode((int)$fileID)); 
  1321. $result = $this->methodCaller("FileService.getDownloadUrl", $carray); 
  1322. return $result; 
  1323.  
  1324. /** 
  1325. * @service Funnel Service 
  1326. */ 
  1327.  
  1328. /** 
  1329. * @method achieveGoal 
  1330. * @description achieves an api goal inside of the Campaign Builder to start a campaign 
  1331. * @param string $integration 
  1332. * @param string $callName 
  1333. * @param int $contactId 
  1334. * @return array 
  1335. */ 
  1336. public function achieveGoal($integration, $callName, $contactId) 
  1337. $carray = array( 
  1338. php_xmlrpc_encode((string)$integration),  
  1339. php_xmlrpc_encode((string)$callName),  
  1340. php_xmlrpc_encode((int)$contactId)); 
  1341. return $this->methodCaller("FunnelService.achieveGoal", $carray); 
  1342.  
  1343. /** 
  1344. * @service Invoice Service 
  1345. */ 
  1346.  
  1347. /** 
  1348. * @method deleteInvoice 
  1349. * @description deletes an invoice 
  1350. * @param int $Id 
  1351. * @return bool 
  1352. */ 
  1353. public function deleteInvoice($Id) 
  1354. $carray = array( 
  1355. php_xmlrpc_encode((int)$Id)); 
  1356. return $this->methodCaller("InvoiceService.deleteInvoice", $carray); 
  1357.  
  1358. /** 
  1359. * @method deleteSubscriptioin 
  1360. * @description Delete a Subscription created through the API 
  1361. * @param $Id 
  1362. * @return bool 
  1363. */ 
  1364. public function deleteSubscription($Id) 
  1365. $carray = array( 
  1366. php_xmlrpc_encode((int)$Id)); 
  1367. return $this->methodCaller("InvoiceService.deleteSubscription", $carray); 
  1368.  
  1369. /** 
  1370. * @method getPayments 
  1371. * @description Get a list of payments on an invoice 
  1372. * @param $Id 
  1373. * @return array 
  1374. */ 
  1375. public function getPayments($Id) 
  1376. $carray = array( 
  1377. php_xmlrpc_encode((int)$Id)); 
  1378. return $this->methodCaller("InvoiceService.getPayments", $carray); 
  1379.  
  1380. /** 
  1381. * @method setInvoiceSyncStatus 
  1382. * @description sets the sync status column on the Invoice table 
  1383. * @param $Id 
  1384. * @param $syncStatus 
  1385. * @return bool 
  1386. */ 
  1387. public function setInvoiceSyncStatus($Id, $syncStatus) 
  1388. $carray = array( 
  1389. php_xmlrpc_encode((int)$Id),  
  1390. php_xmlrpc_encode($syncStatus)); 
  1391. return $this->methodCaller("InvoiceService.setInvoiceSyncStatus", $carray); 
  1392.  
  1393. /** 
  1394. * @method setPaymentSyncStatus 
  1395. * @description sets the sync status column on the Payment table 
  1396. * @param $Id 
  1397. * @param $Status 
  1398. * @return bool 
  1399. */ 
  1400. public function setPaymentSyncStatus($Id, $Status) 
  1401. $carray = array( 
  1402. php_xmlrpc_encode((int)$Id),  
  1403. php_xmlrpc_encode($Status)); 
  1404. return $this->methodCaller("InvoiceService.setPaymentSyncStatus", $carray); 
  1405.  
  1406. /** 
  1407. * @method getPluginStatus 
  1408. * @description Tells if the Ecommerce plugin is enabled 
  1409. * @param string $className 
  1410. * @return bool 
  1411. */ 
  1412. public function getPluginStatus($className) 
  1413. $carray = array( 
  1414. php_xmlrpc_encode($className)); 
  1415. return $this->methodCaller("InvoiceService.getPluginStatus", $carray); 
  1416.  
  1417. /** 
  1418. * @method getAllPaymentOptions 
  1419. * @description get a list of all Payment Options 
  1420. * @return array 
  1421. */ 
  1422. public function getAllPaymentOptions() 
  1423. $carray = array(); 
  1424. return $this->methodCaller("InvoiceService.getAllPaymentOptions", $carray); 
  1425.  
  1426. /** 
  1427. * @method addManualPayment 
  1428. * @description add a manual payment to an invoice. 
  1429. * @note Will not complete Purchase Goals or Successful Purchase Actions 
  1430. * @param int $invId 
  1431. * @param double $amt 
  1432. * @param datetime $payDate 
  1433. * @param datetime $payType 
  1434. * @param string $payDesc 
  1435. * @param bool $bypassComm 
  1436. * @return int 
  1437. */ 
  1438. public function manualPmt($invId, $amt, $payDate, $payType, $payDesc, $bypassComm) 
  1439. $carray = array( 
  1440. php_xmlrpc_encode((int)$invId),  
  1441. php_xmlrpc_encode($amt),  
  1442. php_xmlrpc_encode($payDate, array('auto_dates')),  
  1443. php_xmlrpc_encode($payType),  
  1444. php_xmlrpc_encode($payDesc),  
  1445. php_xmlrpc_encode($bypassComm)); 
  1446. return $this->methodCaller("InvoiceService.addManualPayment", $carray); 
  1447.  
  1448. /** 
  1449. * @method addOrderCommissionOverride 
  1450. * @description Override Order Commissions 
  1451. * @param int $invId 
  1452. * @param int $affId 
  1453. * @param int $prodId 
  1454. * @param int $percentage 
  1455. * @param double $amt 
  1456. * @param int $payType 
  1457. * @param string $desc 
  1458. * @param date $date 
  1459. * @return bool 
  1460. */ 
  1461. public function commOverride($invId, $affId, $prodId, $percentage, $amt, $payType, $desc, $date) 
  1462. $carray = array( 
  1463. php_xmlrpc_encode((int)$invId),  
  1464. php_xmlrpc_encode((int)$affId),  
  1465. php_xmlrpc_encode((int)$prodId),  
  1466. php_xmlrpc_encode($percentage),  
  1467. php_xmlrpc_encode($amt),  
  1468. php_xmlrpc_encode($payType),  
  1469. php_xmlrpc_encode($desc),  
  1470. php_xmlrpc_encode($date, array('auto_dates'))); 
  1471.  
  1472. return $this->methodCaller("InvoiceService.addOrderCommissionOverride", $carray); 
  1473.  
  1474. /** 
  1475. * @method addOrderItem 
  1476. * @description add a line item to an order 
  1477. * @param int $ordId 
  1478. * @param int $prodId 
  1479. * @param int $type 
  1480. * @paramOption 1 Shipping 
  1481. * @paramOption 2 Tax 
  1482. * @paramOption 3 Service & Misc 
  1483. * @paramOption 4 Product 
  1484. * @paramOption 5 Upsell Product 
  1485. * @paramOption 6 Fiance Charge 
  1486. * @paramOption 7 Special 
  1487. * @paramOption 8 Program 
  1488. * @paramOption 9 Subscription Plan 
  1489. * @paramOption 10 Special:Free Trial Days 
  1490. * @paramOption 12 Special: Order Total 
  1491. * @paramOption 13 Special: Category 
  1492. * @paramOption 14 Special: Shipping 
  1493. * @param double $price 
  1494. * @param itn $qty 
  1495. * @param string $desc 
  1496. * @param string $notes 
  1497. * @return bool 
  1498. */ 
  1499. public function addOrderItem($ordId, $prodId, $type, $price, $qty, $desc, $notes) 
  1500. $carray = array( 
  1501. php_xmlrpc_encode((int)$ordId),  
  1502. php_xmlrpc_encode((int)$prodId),  
  1503. php_xmlrpc_encode((int)$type),  
  1504. php_xmlrpc_encode($price),  
  1505. php_xmlrpc_encode($qty),  
  1506. php_xmlrpc_encode($desc),  
  1507. php_xmlrpc_encode($notes)); 
  1508.  
  1509. return $this->methodCaller("InvoiceService.addOrderItem", $carray); 
  1510.  
  1511. /** 
  1512. * @method addPaymentPlan 
  1513. * @description add a payment plan to an order 
  1514. * @param int $ordId 
  1515. * @param bool $aCharge 
  1516. * @param int $ccId 
  1517. * @param int $merchId 
  1518. * @param int $retry 
  1519. * @param int $retryAmt 
  1520. * @param double $initialPmt 
  1521. * @param datetime $initialPmtDate 
  1522. * @param datetime $planStartDate 
  1523. * @param int $numPmts 
  1524. * @param int $pmtDays 
  1525. * @return bool 
  1526. */ 
  1527. public function payPlan($ordId, $aCharge, $ccId, $merchId, $retry, $retryAmt, $initialPmt, $initialPmtDate, $planStartDate, $numPmts, $pmtDays) 
  1528. $carray = array( 
  1529. php_xmlrpc_encode((int)$ordId),  
  1530. php_xmlrpc_encode($aCharge),  
  1531. php_xmlrpc_encode((int)$ccId),  
  1532. php_xmlrpc_encode((int)$merchId),  
  1533. php_xmlrpc_encode((int)$retry),  
  1534. php_xmlrpc_encode((int)$retryAmt),  
  1535. php_xmlrpc_encode($initialPmt),  
  1536. php_xmlrpc_encode($initialPmtDate, array('auto_dates')),  
  1537. php_xmlrpc_encode($planStartDate, array('auto_dates')),  
  1538. php_xmlrpc_encode((int)$numPmts),  
  1539. php_xmlrpc_encode((int)$pmtDays)); 
  1540. return $this->methodCaller("InvoiceService.addPaymentPlan", $carray); 
  1541.  
  1542. /** 
  1543. * @method addRecurringOrder 
  1544. * @description creates a subscription for a contact 
  1545. * @param int $cid 
  1546. * @param bool $allowDup 
  1547. * @param int $progId 
  1548. * @param int $merchId 
  1549. * @param int $ccId 
  1550. * @param int $affId 
  1551. * @param int $daysToCharge 
  1552. * @return int 
  1553. */ 
  1554. public function addRecurring($cid, $allowDup, $progId, $merchId, $ccId, $affId, $daysToCharge) 
  1555. $carray = array( 
  1556. php_xmlrpc_encode((int)$cid),  
  1557. php_xmlrpc_encode($allowDup),  
  1558. php_xmlrpc_encode((int)$progId),  
  1559. php_xmlrpc_encode((int)$merchId),  
  1560. php_xmlrpc_encode((int)$ccId),  
  1561. php_xmlrpc_encode((int)$affId),  
  1562. php_xmlrpc_encode($daysToCharge)); 
  1563. return $this->methodCaller("InvoiceService.addRecurringOrder", $carray); 
  1564.  
  1565. /** 
  1566. * @method addRecurringOrderAdv 
  1567. * @description creates a subscription for a contact 
  1568. * @note Allows Quantity, Price and Tax 
  1569. * @param int $cid 
  1570. * @param bool $allowDup 
  1571. * @param int $progId 
  1572. * @param int $qty 
  1573. * @param double $price 
  1574. * @param bool $allowTax 
  1575. * @param int $merchId 
  1576. * @param int $ccId 
  1577. * @param int $affId 
  1578. * @param int $daysToCharge 
  1579. * @return int 
  1580. */ 
  1581. public function addRecurringAdv($cid, $allowDup, $progId, $qty, $price, $allowTax, $merchId, $ccId, $affId, $daysToCharge) 
  1582. $carray = array( 
  1583. php_xmlrpc_encode((int)$cid),  
  1584. php_xmlrpc_encode($allowDup),  
  1585. php_xmlrpc_encode((int)$progId),  
  1586. php_xmlrpc_encode($qty),  
  1587. php_xmlrpc_encode($price),  
  1588. php_xmlrpc_encode($allowTax),  
  1589. php_xmlrpc_encode($merchId),  
  1590. php_xmlrpc_encode((int)$ccId),  
  1591. php_xmlrpc_encode((int)$affId),  
  1592. php_xmlrpc_encode($daysToCharge)); 
  1593. return $this->methodCaller("InvoiceService.addRecurringOrder", $carray); 
  1594.  
  1595. /** 
  1596. * @method calculateAmountOwed 
  1597. * @description calculate amount owed on an invoice 
  1598. * @param int $invId 
  1599. * @return double 
  1600. */ 
  1601. public function amtOwed($invId) 
  1602. $carray = array( 
  1603. php_xmlrpc_encode((int)$invId)); 
  1604. return $this->methodCaller("InvoiceService.calculateAmountOwed", $carray); 
  1605.  
  1606. /** 
  1607. * @method getInvoiceId 
  1608. * @description get an Invoice Id attached to a one-time order 
  1609. * @param int $orderId 
  1610. * @return int 
  1611. */ 
  1612. public function getInvoiceId($orderId) 
  1613. $carray = array( 
  1614. php_xmlrpc_encode((int)$orderId)); 
  1615. return $this->methodCaller("InvoiceService.getInvoiceId", $carray); 
  1616.  
  1617. /** 
  1618. * @method getOrderId 
  1619. * @description get the Order Id associated with an Invoice 
  1620. * @param int $invoiceId 
  1621. * @return int 
  1622. */ 
  1623. public function getOrderId($invoiceId) 
  1624. $carray = array( 
  1625. php_xmlrpc_encode((int)$invoiceId)); 
  1626. return $this->methodCaller("InvoiceService.getOrderId", $carray); 
  1627.  
  1628. /** 
  1629. * @method chargeInvoice 
  1630. * @description Charges an invoice immediately 
  1631. * @param int $invId 
  1632. * @param string $notes 
  1633. * @param int $ccId 
  1634. * @param int $merchId 
  1635. * @param bool $bypassComm 
  1636. * @return array 
  1637. */ 
  1638. public function chargeInvoice($invId, $notes, $ccId, $merchId, $bypassComm) 
  1639. $carray = array( 
  1640. php_xmlrpc_encode((int)$invId),  
  1641. php_xmlrpc_encode($notes),  
  1642. php_xmlrpc_encode((int)$ccId),  
  1643. php_xmlrpc_encode((int)$merchId),  
  1644. php_xmlrpc_encode($bypassComm)); 
  1645. return $this->methodCaller("InvoiceService.chargeInvoice", $carray); 
  1646.  
  1647. /** 
  1648. * @method createBlankOrder 
  1649. * @description creates a blank order for a contact 
  1650. * @param int $conId 
  1651. * @param string $desc 
  1652. * @param date $oDate 
  1653. * @param int $leadAff 
  1654. * @param int $saleAff 
  1655. * @return int 
  1656. */ 
  1657. public function blankOrder($conId, $desc, $oDate, $leadAff, $saleAff) 
  1658. $carray = array( 
  1659. php_xmlrpc_encode((int)$conId),  
  1660. php_xmlrpc_encode($desc),  
  1661. php_xmlrpc_encode($oDate, array('auto_dates')),  
  1662. php_xmlrpc_encode((int)$leadAff),  
  1663. php_xmlrpc_encode((int)$saleAff)); 
  1664. return $this->methodCaller("InvoiceService.createBlankOrder", $carray); 
  1665.  
  1666. /** 
  1667. * @method createInvoiceForRecurring 
  1668. * @description creates an invoice for a subscription 
  1669. * @param int $rid 
  1670. * @return int 
  1671. */ 
  1672. public function recurringInvoice($rid) 
  1673. $carray = array( 
  1674. php_xmlrpc_encode((int)$rid)); 
  1675. return $this->methodCaller("InvoiceService.createInvoiceForRecurring", $carray); 
  1676.  
  1677. /** 
  1678. * @method locateExistingCard 
  1679. * @description locates a creditcard Id from based on the last 4 digits 
  1680. * @param int $cid 
  1681. * @param string $last4 
  1682. * @return int 
  1683. */ 
  1684. public function locateCard($cid, $last4) 
  1685. $carray = array( 
  1686. php_xmlrpc_encode((int)$cid),  
  1687. php_xmlrpc_encode($last4)); 
  1688. return $this->methodCaller("InvoiceService.locateExistingCard", $carray); 
  1689.  
  1690. /** 
  1691. * @method validateCreditCard 
  1692. * @description Validates a Credit Card 
  1693. * @note this will take a CC ID or a CC array 
  1694. * @param mixed $creditCard 
  1695. * @return int 
  1696. */ 
  1697. public function validateCard($creditCard) 
  1698. $creditCard = is_array($creditCard) ? $creditCard : (int)$creditCard; 
  1699.  
  1700. $carray = array( 
  1701. php_xmlrpc_encode($creditCard)); 
  1702. return $this->methodCaller("InvoiceService.validateCreditCard", $carray); 
  1703.  
  1704. /** 
  1705. * @method updateSubscriptionNextBillDate 
  1706. * @description Updates the Next Bill Date on a Subscription 
  1707. * @param int $subscriptionId 
  1708. * @param date $nextBillDate 
  1709. * @return bool 
  1710. */ 
  1711. public function updateSubscriptionNextBillDate($subscriptionId, $nextBillDate) 
  1712. $carray = array( 
  1713. php_xmlrpc_encode((int)$subscriptionId),  
  1714. php_xmlrpc_encode($nextBillDate, array('auto_dates'))); 
  1715. return $this->methodCaller("InvoiceService.updateJobRecurringNextBillDate", $carray); 
  1716.  
  1717. /** 
  1718. * @method recalculateTax 
  1719. * @description recalculates tax for a given invoice Id 
  1720. * @param $invoiceId 
  1721. * @return bool 
  1722. */ 
  1723. public function recalculateTax($invoiceId) 
  1724. $carray = array( 
  1725. php_xmlrpc_encode((int)$invoiceId)); 
  1726. return $this->methodCaller("InvoiceService.recalculateTax", $carray); 
  1727.  
  1728. /** 
  1729. * @service Misc iSDK Functions 
  1730. */ 
  1731.  
  1732. /** 
  1733. * @method infuDate 
  1734. * @description returns properly formatted dates. 
  1735. * @param $dateStr 
  1736. * @param $dateFrmt - Optional date format for UK formatted Applications 
  1737. * @return bool|string 
  1738. */ 
  1739. public function infuDate($dateStr, $dateFrmt = 'US') 
  1740. $dArray = date_parse($dateStr); 
  1741. if ($dArray['error_count'] < 1) { 
  1742. $tStamp = 
  1743. mktime($dArray['hour'], $dArray['minute'], $dArray['second'], $dArray['month'],  
  1744. $dArray['day'], $dArray['year']); 
  1745. if ($dateFrmt == 'UK') { 
  1746. setlocale(LC_ALL, 'en_GB'); 
  1747. return date('Y-d-m\TH:i:s', $tStamp); 
  1748. } else { 
  1749. return date('Ymd\TH:i:s', $tStamp); 
  1750. } else { 
  1751. foreach ($dArray['errors'] as $err) { 
  1752. echo "ERROR: " . $err . "<br />"; 
  1753. die("The above errors prevented the application from executing properly."); 
  1754.  
  1755. /** 
  1756. * @method enableLogging 
  1757. * @description Function to Enable/Disable Logging 
  1758. * @param int $log 
  1759. */ 
  1760. public function enableLogging($log) 
  1761. $this->loggingEnabled = $log; 
  1762.  
  1763. /** 
  1764. * @method getHandle 
  1765. * @description Creates CSV Resource 
  1766. * @param string $logname 
  1767. * @return resource 
  1768. */ 
  1769. static protected function getHandle($logname) 
  1770. if (!is_resource(self::$handle)) { 
  1771. self::$handle = fopen($logname, 'a+'); 
  1772. return self::$handle; 
  1773.  
  1774. /** 
  1775. * @method log 
  1776. * @description Function for Logging Calls 
  1777. * @param array $data 
  1778. * @return mixed 
  1779. */ 
  1780. private function log($data) 
  1781. $logdata = $data; 
  1782.  
  1783. if ($this->logname == '') { 
  1784. $logname = dirname(__FILE__) . '/apilog.csv'; 
  1785. } else { 
  1786. $logname = $this->logname; 
  1787.  
  1788. if (!file_exists($logname)) { 
  1789. $this->getHandle($logname); 
  1790. fputcsv(self::$handle, array('Date', 'Method', 'Call', 'Start Time', 'Stop Time', 'Execution Time', 'Result', 'Error', 'Error Code')); 
  1791. } else { 
  1792. $this->getHandle($logname); 
  1793.  
  1794. if (isset($logdata['Call'][0]->me['string'])) { 
  1795. if ($logdata['Call'][0]->me['string'] == 'CreditCard') { 
  1796. unset($logdata['Call'][1]->me['struct']); 
  1797. $logdata['Call'][1]->me['struct'] = 'Data Removed For Security'; 
  1798.  
  1799. $logdata['Call'][0]->me['string'] = 'APIKEY'; 
  1800.  
  1801. fputcsv(self::$handle, array( 
  1802. date('Y-m-d H:i:s', $logdata['Now']),  
  1803. $logdata['Method'],  
  1804. print_r(serialize($logdata['Call']), true),  
  1805. $logdata['Start'],  
  1806. $logdata['Stop'],  
  1807. ($logdata['Stop'] - $logdata['Start']),  
  1808. print_r(serialize($logdata['Result']), true),  
  1809. $logdata['Error'],  
  1810. $logdata['ErrorCode'] 
  1811. )); 
  1812. fclose(self::$handle); 
  1813.  
  1814.  
  1815. public function setLog($logPath) 
  1816. $this->logname = $logPath; 
  1817.  
  1818. /** 
  1819. * @service Order Service 
  1820. */ 
  1821.  
  1822. /** 
  1823. * @method placeOrder 
  1824. * @description Builds, creates and charges an order. 
  1825. * @param int $contactId 
  1826. * @param int $creditCardId 
  1827. * @param int $payPlanId 
  1828. * @param array $productIds 
  1829. * @param array $subscriptionIds 
  1830. * @param bool $processSpecials 
  1831. * @param array $promoCodes 
  1832. * @param int $leadAff 
  1833. * @param int $saleAff 
  1834. * @return array 
  1835. */ 
  1836. public function placeOrder($contactId, $creditCardId, $payPlanId, $productIds, $subscriptionIds, $processSpecials, $promoCodes, $leadAff = 0, $saleAff = 0) 
  1837. $carray = array( 
  1838. php_xmlrpc_encode((int)$contactId),  
  1839. php_xmlrpc_encode((int)$creditCardId),  
  1840. php_xmlrpc_encode((int)$payPlanId),  
  1841. php_xmlrpc_encode($productIds),  
  1842. php_xmlrpc_encode($subscriptionIds),  
  1843. php_xmlrpc_encode($processSpecials),  
  1844. php_xmlrpc_encode($promoCodes),  
  1845. php_xmlrpc_encode((int)$leadAff),  
  1846. php_xmlrpc_encode((int)$saleAff)); 
  1847. return $this->methodCaller("OrderService.placeOrder", $carray); 
  1848.  
  1849. /** 
  1850. * @service Product Service 
  1851. */ 
  1852.  
  1853. /** 
  1854. * @method getInventory 
  1855. * @description retrieves the current inventory level for a specific product 
  1856. * @param int $productId 
  1857. * @return int 
  1858. */ 
  1859. public function getInventory($productId) 
  1860. $carray = array( 
  1861. php_xmlrpc_encode((int)$productId)); 
  1862. return $this->methodCaller("ProductService.getInventory", $carray); 
  1863.  
  1864. /** 
  1865. * @method incrementInventory 
  1866. * @description increments current inventory level by 1 
  1867. * @param int $productId 
  1868. * @return bool 
  1869. */ 
  1870. public function incrementInventory($productId) 
  1871. $carray = array( 
  1872. php_xmlrpc_encode((int)$productId)); 
  1873. return $this->methodCaller("ProductService.incrementInventory", $carray); 
  1874.  
  1875. /** 
  1876. * @method decrementInventory 
  1877. * @description decrements current inventory level by 1 
  1878. * @param int $productId 
  1879. * @return bool 
  1880. */ 
  1881. function decrementInventory($productId) 
  1882. $carray = array( 
  1883. php_xmlrpc_encode((int)$productId)); 
  1884. return $this->methodCaller("ProductService.decrementInventory", $carray); 
  1885.  
  1886. /** 
  1887. * @method increaseInventory 
  1888. * @description increases inventory levels 
  1889. * @param int $productId 
  1890. * @param int $quantity 
  1891. * @return bool 
  1892. */ 
  1893. public function increaseInventory($productId, $quantity) 
  1894. $carray = array( 
  1895. php_xmlrpc_encode((int)$productId),  
  1896. php_xmlrpc_encode((int)$quantity)); 
  1897. return $this->methodCaller("ProductService.increaseInventory", $carray); 
  1898.  
  1899. /** 
  1900. * @method decreaseInventory 
  1901. * @description decreases inventory levels 
  1902. * @param int $productId 
  1903. * @param int $quantity 
  1904. * @return bool 
  1905. */ 
  1906. public function decreaseInventory($productId, $quantity) 
  1907. $carray = array( 
  1908. php_xmlrpc_encode((int)$productId),  
  1909. php_xmlrpc_encode((int)$quantity)); 
  1910. return $this->methodCaller("ProductService.decreaseInventory", $carray); 
  1911.  
  1912. /** 
  1913. * @method deactivateCreditCard 
  1914. * @description deactivate a credit card 
  1915. * @param int $creditCardId 
  1916. * @return bool 
  1917. */ 
  1918. public function deactivateCreditCard($creditCardId) 
  1919. $carray = array( 
  1920. php_xmlrpc_encode((int)$creditCardId)); 
  1921. return $this->methodCaller("ProductService.deactivateCreditCard", $carray); 
  1922.  
  1923. /** 
  1924. * @service Search Service 
  1925. */ 
  1926.  
  1927. /** 
  1928. * @method getSavedSearchResultsAllFields 
  1929. * @description returns a saved search with all fields 
  1930. * @param int $savedSearchId 
  1931. * @param int $userId 
  1932. * @param int $page 
  1933. * @return array 
  1934. */ 
  1935. public function savedSearchAllFields($savedSearchId, $userId, $page) 
  1936. $carray = array( 
  1937. php_xmlrpc_encode((int)$savedSearchId),  
  1938. php_xmlrpc_encode((int)$userId),  
  1939. php_xmlrpc_encode((int)$page)); 
  1940. return $this->methodCaller("SearchService.getSavedSearchResultsAllFields", $carray); 
  1941.  
  1942. /** 
  1943. * @method getSavedSearchResults 
  1944. * @description returns a saved search with selected fields 
  1945. * @param int $savedSearchId 
  1946. * @param int $userId 
  1947. * @param int $page 
  1948. * @param array $fields 
  1949. * @return array 
  1950. */ 
  1951. public function savedSearch($savedSearchId, $userId, $page, $fields) 
  1952. $carray = array( 
  1953. php_xmlrpc_encode((int)$savedSearchId),  
  1954. php_xmlrpc_encode((int)$userId),  
  1955. php_xmlrpc_encode((int)$page),  
  1956. php_xmlrpc_encode($fields)); 
  1957. return $this->methodCaller("SearchService.getSavedSearchResults", $carray); 
  1958.  
  1959. /** 
  1960. * @method getAllReportColumns 
  1961. * @description returns the fields available in a saved report 
  1962. * @param int $savedSearchId 
  1963. * @param int $userId 
  1964. * @return array 
  1965. */ 
  1966. public function getAvailableFields($savedSearchId, $userId) 
  1967. $carray = array( 
  1968. php_xmlrpc_encode((int)$savedSearchId),  
  1969. php_xmlrpc_encode((int)$userId)); 
  1970. return $this->methodCaller("SearchService.getAllReportColumns", $carray); 
  1971.  
  1972. /** 
  1973. * @method getDefaultQuickSearch 
  1974. * @description returns the default quick search type for a user 
  1975. * @param int $userId 
  1976. * @return array 
  1977. */ 
  1978. public function getDefaultQuickSearch($userId) 
  1979. $carray = array( 
  1980. php_xmlrpc_encode((int)$userId)); 
  1981. return $this->methodCaller("SearchService.getDefaultQuickSearch", $carray); 
  1982.  
  1983. /** 
  1984. * @method getAvailableQuickSearches 
  1985. * @description returns the available quick search types 
  1986. * @param int $userId 
  1987. * @return array 
  1988. */ 
  1989. public function getQuickSearches($userId) 
  1990. $carray = array( 
  1991. php_xmlrpc_encode((int)$userId)); 
  1992. return $this->methodCaller("SearchService.getAvailableQuickSearches", $carray); 
  1993.  
  1994. /** 
  1995. * @method quickSearch 
  1996. * @description returns the results of a quick search 
  1997. * @param int $quickSearchType 
  1998. * @param int $userId 
  1999. * @param string $filterData 
  2000. * @param int $page 
  2001. * @param int $limit 
  2002. * @return array 
  2003. */ 
  2004. public function quickSearch($quickSearchType, $userId, $filterData, $page, $limit) 
  2005. $carray = array( 
  2006. php_xmlrpc_encode($quickSearchType),  
  2007. php_xmlrpc_encode((int)$userId),  
  2008. php_xmlrpc_encode($filterData),  
  2009. php_xmlrpc_encode((int)$page),  
  2010. php_xmlrpc_encode((int)$limit)); 
  2011. return $this->methodCaller("SearchService.quickSearch", $carray); 
  2012.  
  2013. /** 
  2014. * @service Service Call Service 
  2015. * @note also known as Ticket System. This service is deprecated 
  2016. */ 
  2017.  
  2018. /** 
  2019. * @method addMoveNotes 
  2020. * @description Adds move notes to existing tickets 
  2021. * @param array $ticketList 
  2022. * @param string $moveNotes 
  2023. * @param int $moveToStageId 
  2024. * @param int $notifyIds 
  2025. * @return bool 
  2026. */ 
  2027. public function addMoveNotes($ticketList, $moveNotes, $moveToStageId, $notifyIds) 
  2028. $carray = array( 
  2029. php_xmlrpc_encode($ticketList),  
  2030. php_xmlrpc_encode($moveNotes),  
  2031. php_xmlrpc_encode($moveToStageId),  
  2032. php_xmlrpc_encode($notifyIds)); 
  2033. return $this->methodCaller("ServiceCallService.addMoveNotes", $carray); 
  2034.  
  2035. /** 
  2036. * @method moveTicketStage 
  2037. * @description Moves a Ticket Stage 
  2038. * @param int $ticketID 
  2039. * @param string $ticketStage 
  2040. * @param string $moveNotes 
  2041. * @param string $notifyIds 
  2042. * @return bool 
  2043. */ 
  2044. public function moveTicketStage($ticketID, $ticketStage, $moveNotes, $notifyIds) 
  2045. $carray = array( 
  2046. php_xmlrpc_encode((int)$ticketID),  
  2047. php_xmlrpc_encode($ticketStage),  
  2048. php_xmlrpc_encode($moveNotes),  
  2049. php_xmlrpc_encode($notifyIds)); 
  2050. return $this->methodCaller("ServiceCallService.moveTicketStage", $carray); 
  2051.  
  2052. /** 
  2053. * @service Shipping Service 
  2054. */ 
  2055.  
  2056. /** 
  2057. * @method getAllShippingOptions 
  2058. * @description get a list of shipping methods 
  2059. * @return array 
  2060. */ 
  2061. public function getAllShippingOptions() 
  2062. $carray = array(); 
  2063. return $this->methodCaller("ShippingService.getAllShippingOptions", $carray); 
  2064.  
  2065. /** 
  2066. * @method getAllConfiguredShippingOptions 
  2067. * @description get a list of shipping methods 
  2068. * @return array 
  2069. */ 
  2070. public function getAllConfiguredShippingOptions() 
  2071. $carray = array(); 
  2072. return $this->methodCaller("ShippingService.getAllShippingOptions", $carray); 
  2073.  
  2074. /** 
  2075. * @method getFlatRateShippingOption 
  2076. * @description retrieves details on a flat rate type shipping option 
  2077. * @param int $optionId 
  2078. * @return array 
  2079. */ 
  2080. public function getFlatRateShippingOption($optionId) 
  2081. $carray = array( 
  2082. php_xmlrpc_encode((int)$optionId)); 
  2083. return $this->methodCaller("ShippingService.getFlatRateShippingOption", $carray); 
  2084.  
  2085. /** 
  2086. * @method getOrderTotalShippingOption 
  2087. * @description retrieves details on a order total type shipping option 
  2088. * @param int $optionId 
  2089. * @return array 
  2090. */ 
  2091. public function getOrderTotalShippingOption($optionId) 
  2092. $carray = array( 
  2093. php_xmlrpc_encode((int)$optionId)); 
  2094. return $this->methodCaller("ShippingService.getOrderTotalShippingOption", $carray); 
  2095.  
  2096. /** 
  2097. * @method getOrderTotalShippingRanges 
  2098. * @description retrieves the pricing range details for the given Order Total shipping option 
  2099. * @param int $optionId 
  2100. * @return array 
  2101. */ 
  2102. public function getOrderTotalShippingRanges($optionId) 
  2103. $carray = array( 
  2104. php_xmlrpc_encode((int)$optionId)); 
  2105. return $this->methodCaller("ShippingService.getOrderTotalShippingRanges", $carray); 
  2106.  
  2107. /** 
  2108. * @method getProductBasedShippingOption 
  2109. * @description retrieves details on a product based type shipping option 
  2110. * @param int $optionId 
  2111. * @return array 
  2112. */ 
  2113. public function getProductBasedShippingOption($optionId) 
  2114. $carray = array( 
  2115. php_xmlrpc_encode((int)$optionId)); 
  2116. return $this->methodCaller("ShippingService.getProductBasedShippingOption", $carray); 
  2117.  
  2118. /** 
  2119. * @method getProductShippingPricesForProductShippingOption 
  2120. * @description retrieves the pricing for your per product shipping options 
  2121. * @param int $optionId 
  2122. * @return array 
  2123. */ 
  2124. public function getProductShippingPricesForProductShippingOption($optionId) 
  2125. $carray = array( 
  2126. php_xmlrpc_encode((int)$optionId)); 
  2127. return $this->methodCaller("ShippingService.getProductShippingPricesForProductShippingOption", $carray); 
  2128.  
  2129. /** 
  2130. * @method getOrderQuantityShippingOption 
  2131. * @description retrieves details on a order quantity type shipping option 
  2132. * @param int $optionId 
  2133. * @return array 
  2134. */ 
  2135. public function getOrderQuantityShippingOption($optionId) 
  2136. $carray = array( 
  2137. php_xmlrpc_encode((int)$optionId)); 
  2138. return $this->methodCaller("ShippingService.getOrderQuantityShippingOption", $carray); 
  2139.  
  2140. /** 
  2141. * @method getWeightBasedShippingOption 
  2142. * @description retrieves details on a weight based type shipping option 
  2143. * @param int $optionId 
  2144. * @return array 
  2145. */ 
  2146. public function getWeightBasedShippingOption($optionId) 
  2147. $carray = array( 
  2148. php_xmlrpc_encode((int)$optionId)); 
  2149. return $this->methodCaller("ShippingService.getWeightBasedShippingOption", $carray); 
  2150.  
  2151. /** 
  2152. * @method getWeightBasedShippingRanges 
  2153. * @description retrieves the weight ranges for a weight based type shipping option 
  2154. * @param int $optionId 
  2155. * @return array 
  2156. */ 
  2157. public function getWeightBasedShippingRanges($optionId) 
  2158. $carray = array( 
  2159. php_xmlrpc_encode((int)$optionId)); 
  2160. return $this->methodCaller("ShippingService.getWeightBasedShippingRanges", $carray); 
  2161.  
  2162. /** 
  2163. * @method getUpsShippingOption 
  2164. * @description retrieves the details around a UPS type shipping option 
  2165. * @param int $optionId 
  2166. * @return array 
  2167. */ 
  2168. public function getUpsShippingOption($optionId) 
  2169. $carray = array( 
  2170. php_xmlrpc_encode((int)$optionId)); 
  2171. return $this->methodCaller("ShippingService.getUpsShippingOption", $carray); 
  2172.  
  2173. /** 
  2174. * @service Web Form Service 
  2175. */ 
  2176.  
  2177. /** 
  2178. * @method getMap 
  2179. * @description returns web form titles and Id numbers from the application 
  2180. * @return array 
  2181. */ 
  2182. public function getWebFormMap() 
  2183. $carray = array(); 
  2184. return $this->methodCaller("WebFormService.getMap", $carray); 
  2185.  
  2186. /** 
  2187. * @method getHTML 
  2188. * @description returns the HTML for the given web form 
  2189. * @param int $webFormId 
  2190. * @return string 
  2191. */ 
  2192. public function getWebFormHtml($webFormId = 0) 
  2193. $carray = array( 
  2194. php_xmlrpc_encode((int)$webFormId)); 
  2195. return $this->methodCaller("WebFormService.getHTML", $carray); 
  2196.  
  2197. /** 
  2198. * @service Web Tracking Service 
  2199. */ 
  2200.  
  2201. /** 
  2202. * @method getWebTrackingScriptTag 
  2203. * @description returns the web tracking javascript code 
  2204. * @return string 
  2205. */ 
  2206. public function getWebTrackingServiceTag() 
  2207. $carray = array(); 
  2208. return $this->methodCaller("WebTrackingService.getWebTrackingScriptTag", $carray); 
  2209.  
  2210. /** 
  2211. * @method getWebTrackingScriptUrl 
  2212. * @description returns the url for the web tracking code 
  2213. * @return string 
  2214. */ 
  2215. public function getWebTrackingScriptUrl() 
  2216. $carray = array(); 
  2217. return $this->methodCaller("WebTrackingService.getWebTrackingScriptUrl", $carray); 
  2218.