isdk.php 77 KB

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