/soapclient/SforceEnterpriseClient.php

http://forceworkbench.googlecode.com/ · PHP · 111 lines · 39 code · 7 blank · 65 comment · 0 complexity · e6e658c0bcd4c3ab7ed8e62b1a2ff455 MD5 · raw file

  1. <?php
  2. /*
  3. * Copyright (c) 2007, salesforce.com, inc.
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification, are permitted provided
  7. * that the following conditions are met:
  8. *
  9. * Redistributions of source code must retain the above copyright notice, this list of conditions and the
  10. * following disclaimer.
  11. *
  12. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
  13. * the following disclaimer in the documentation and/or other materials provided with the distribution.
  14. *
  15. * Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or
  16. * promote products derived from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
  19. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  20. * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  21. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  22. * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  23. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  25. * POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. require_once 'SforceBaseClient.php';
  28. /**
  29. * This file contains two classes.
  30. * @package SalesforceSoapClient
  31. */
  32. /**
  33. * SforceEnterpriseClient class.
  34. *
  35. * @package SalesforceSoapClient
  36. */
  37. class SforceEnterpriseClient extends SforceBaseClient {
  38. const ENTERPRISE_NAMESPACE = 'urn:enterprise.soap.sforce.com';
  39. function SforceEnterpriseClient() {
  40. $this->namespace = self::ENTERPRISE_NAMESPACE;
  41. }
  42. /**
  43. * Adds one or more new individual objects to your organization's data.
  44. * @param array $sObjects Array of one or more sObjects (up to 200) to create.
  45. * @param AssignmentRuleHeader $assignmentHeader is optional. Defaults to NULL
  46. * @param MruHeader $mruHeader is optional. Defaults to NULL
  47. * @return SaveResult
  48. */
  49. public function create($sObjects, $type) {
  50. foreach ($sObjects as &$sobject) {
  51. $sobject = new SoapVar($sobject, SOAP_ENC_OBJECT, $type, $this->namespace);
  52. }
  53. $arg = $sObjects;
  54. return parent::_create(new SoapParam($arg, "sObjects"));
  55. }
  56. /**
  57. * Updates one or more new individual objects to your organization's data.
  58. * @param array sObjects Array of sObjects
  59. * @param AssignmentRuleHeader $assignmentHeader is optional. Defaults to NULL
  60. * @param MruHeader $mruHeader is optional. Defaults to NULL
  61. * @return UpdateResult
  62. */
  63. public function update($sObjects, $type, $assignmentHeader = NULL, $mruHeader = NULL) {
  64. foreach ($sObjects as &$sObject) {
  65. $sObject = new SoapVar($sObject, SOAP_ENC_OBJECT, $type, $this->namespace);
  66. }
  67. $arg = new stdClass;
  68. $arg->sObjects = $sObjects;
  69. return parent::_update($arg);
  70. }
  71. /**
  72. * Creates new objects and updates existing objects; uses a custom field to
  73. * determine the presence of existing objects. In most cases, we recommend
  74. * that you use upsert instead of create because upsert is idempotent.
  75. * Available in the API version 7.0 and later.
  76. *
  77. * @param string $extId External Id
  78. * @param array $sObjects Array of sObjects
  79. * @return UpsertResult
  80. */
  81. public function upsert($extId, $sObjects) {
  82. $arg = new stdClass;
  83. $arg->externalIDFieldName = new SoapVar($extId, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');
  84. foreach ($sObjects as &$sObject) {
  85. $sObject = new SoapVar($sObject, SOAP_ENC_OBJECT, 'Contact', $this->namespace);
  86. }
  87. $arg->sObjects = $sObjects;
  88. return parent::_upsert($arg);
  89. }
  90. /**
  91. * Merge records
  92. *
  93. * @param stdclass $mergeRequest
  94. * @param String $type
  95. * @return unknown
  96. */
  97. public function merge($mergeRequest, $type) {
  98. $mergeRequest->masterRecord = new SoapVar($mergeRequest->masterRecord, SOAP_ENC_OBJECT, $type, $this->namespace);
  99. $arg = new stdClass;
  100. $arg->request = new SoapVar($mergeRequest, SOAP_ENC_OBJECT, 'MergeRequest', $this->namespace);
  101. return parent::_merge($arg);
  102. }
  103. }
  104. ?>