| Total Complexity | 29 |
| Total Lines | 220 |
| Duplicated Lines | 0 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class MySalesForcePartnerAPI extends Partner |
||
| 9 | { |
||
| 10 | |||
| 11 | protected $connection = null; |
||
| 12 | |||
| 13 | public function __construct() |
||
| 14 | { |
||
| 15 | parent::__construct(); |
||
| 16 | $this->connection = MySalesForcePartnerAPIConnectionOnly::singleton(); |
||
| 17 | } |
||
| 18 | |||
| 19 | /** |
||
| 20 | * todo: all nullify thingy |
||
| 21 | * assumes that all fields are correct (e.g. correct email format) |
||
| 22 | * can use email or phone as identifier |
||
| 23 | * @param array $fieldsArray |
||
| 24 | * @param array $extraFilterArray -independent additional filters for retrieving contact |
||
| 25 | * |
||
| 26 | * @return SForce\Wsdl\SaveResult|null |
||
| 27 | */ |
||
| 28 | public static function create_contact($fieldsArray, $extraFilterArray = []) |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * todo: all nullify thingy |
||
| 49 | * assumes that all fields are correct (e.g. correct email format) |
||
| 50 | * can use email or phone as identifier |
||
| 51 | * @param array $fieldsArray |
||
| 52 | * @param array $extraFilterArray -independent additional filters for retrieving contact |
||
| 53 | * |
||
| 54 | * @return SForce\Wsdl\SaveResult|null |
||
| 55 | */ |
||
| 56 | public static function update_contact($fieldsArray, $extraFilterArray = []) |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * Retrive a contact by email address or by phone number |
||
| 80 | * either the email (preferred) of phone needs to be set in the $fieldsArray |
||
| 81 | * |
||
| 82 | * @param array $fieldsArray |
||
| 83 | * @param array $extraFilterArray additional filter key-value sets |
||
| 84 | * |
||
| 85 | * @return SForce\SObject|null |
||
| 86 | */ |
||
| 87 | public static function retrieve_contact($fieldsArray, $extraFilterArray = []) |
||
| 121 | } |
||
| 122 | |||
| 123 | /** |
||
| 124 | * turns key value pairs into string |
||
| 125 | * @param array $array [description] |
||
| 126 | * @return string |
||
| 127 | */ |
||
| 128 | protected static function array2sql($array) : string |
||
| 129 | { |
||
| 130 | if(count($array) === 0) { |
||
| 131 | user_error('must have at least one entry'); |
||
| 132 | } |
||
| 133 | $inner = []; |
||
| 134 | foreach($array as $field => $value) { |
||
| 135 | $inner[$field] = $field.' = '.Convert::raw2sql($value, true); |
||
|
1 ignored issue
–
show
|
|||
| 136 | } |
||
| 137 | |||
| 138 | return implode(' AND ', $inner); |
||
| 139 | } |
||
| 140 | |||
| 141 | public function debug() |
||
| 142 | { |
||
| 143 | $xml = $this->getLastRequest(); |
||
| 144 | |||
| 145 | if (! $xml) { |
||
| 146 | return null; |
||
| 147 | } |
||
| 148 | $domxml = new \DOMDocument('1.0'); |
||
| 149 | $domxml->preserveWhiteSpace = false; |
||
| 150 | $domxml->formatOutput = true; |
||
| 151 | /* @var $xml SimpleXMLElement */ |
||
| 152 | $domxml->loadXML($xml); |
||
| 153 | echo $domxml->saveXML(); |
||
| 154 | } |
||
| 155 | |||
| 156 | ##################################### |
||
| 157 | # overriding parent class to fix bugs |
||
| 158 | # in the parent class. |
||
| 159 | ##################################### |
||
| 160 | /** |
||
| 161 | * Adds one or more new individual objects to your organization's data. |
||
| 162 | * |
||
| 163 | * @param SObject[] $sObjects Array of one or more sObjects (up to 200) to create. |
||
| 164 | * @param null|string $type Unused |
||
| 165 | * |
||
| 166 | * @return SaveResult |
||
| 167 | */ |
||
| 168 | public function create($sObjects, $type = null) |
||
| 179 | } |
||
| 180 | |||
| 181 | ##################################### |
||
| 182 | # overriding parent class to fix bugs |
||
| 183 | # in the parent class. |
||
| 184 | ##################################### |
||
| 185 | /** |
||
| 186 | * Updates one or more new individual objects to your organization's data. |
||
| 187 | * |
||
| 188 | * @param SObject[] $sObjects Array of one or more sObjects (up to 200) to update. |
||
| 189 | * @param null|string $type Unused |
||
| 190 | * |
||
| 191 | * @return SaveResult |
||
| 192 | */ |
||
| 193 | public function update($sObjects, $type = null) |
||
|
1 ignored issue
–
show
|
|||
| 194 | { |
||
| 195 | foreach ($sObjects as $sObject) { |
||
| 196 | if (property_exists($sObject, 'fields')) { |
||
| 197 | $sObject->setAny($this->_convertToAny($sObject->getFields())); |
||
|
1 ignored issue
–
show
|
|||
| 198 | } |
||
| 199 | } |
||
| 200 | $updateObject = new SForce\Wsdl\update($sObjects); |
||
| 201 | |||
| 202 | return parent::_update($updateObject); |
||
| 203 | } |
||
| 204 | |||
| 205 | /** |
||
| 206 | * NOTA BENE: |
||
| 207 | * added here because Describe Layout occurs two times (double) with capital D |
||
| 208 | * (DescribeLayout) and without capital D (changed to describeLayoutDouble) |
||
| 209 | * |
||
| 210 | * Use describeLayoutDouble to retrieve information about the layout (presentation |
||
| 211 | * of data to users) for a given object type. The describeLayoutDouble call returns |
||
| 212 | * metadata about a given page layout, including layouts for edit and |
||
| 213 | * display-only views and record type mappings. Note that field-level security |
||
| 214 | * and layout editability affects which fields appear in a layout. |
||
| 215 | * |
||
| 216 | * @param string $type Object Type |
||
| 217 | * @param array $recordTypeIds |
||
| 218 | * |
||
| 219 | * @return Wsdl\DescribeLayoutResult |
||
|
1 ignored issue
–
show
|
|||
| 220 | */ |
||
| 221 | public function describeLayoutDouble($type, array $recordTypeIds = []) |
||
| 228 | } |
||
| 229 | } |
||
| 230 |