@@ -22,27 +22,27 @@ discard block |
||
22 | 22 | public $conditions = array(); |
23 | 23 | |
24 | 24 | /** |
25 | - * Constructor which sets the query object type. |
|
26 | - * |
|
27 | - * @param string $object_type |
|
28 | - * Salesforce object type to query. |
|
29 | - */ |
|
25 | + * Constructor which sets the query object type. |
|
26 | + * |
|
27 | + * @param string $object_type |
|
28 | + * Salesforce object type to query. |
|
29 | + */ |
|
30 | 30 | public function __construct( $object_type = '' ) { |
31 | 31 | $this->object_type = $object_type; |
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
35 | - * Add a condition to the query. |
|
36 | - * |
|
37 | - * @param string $field |
|
38 | - * Field name. |
|
39 | - * @param mixed $value |
|
40 | - * Condition value. If an array, it will be split into quote enclosed |
|
41 | - * strings separated by commas inside of parenthesis. Note that the caller |
|
42 | - * must enclose the value in quotes as needed by the SF API. |
|
43 | - * @param string $operator |
|
44 | - * Conditional operator. One of '=', '!=', '<', '>', 'LIKE, 'IN', 'NOT IN'. |
|
45 | - */ |
|
35 | + * Add a condition to the query. |
|
36 | + * |
|
37 | + * @param string $field |
|
38 | + * Field name. |
|
39 | + * @param mixed $value |
|
40 | + * Condition value. If an array, it will be split into quote enclosed |
|
41 | + * strings separated by commas inside of parenthesis. Note that the caller |
|
42 | + * must enclose the value in quotes as needed by the SF API. |
|
43 | + * @param string $operator |
|
44 | + * Conditional operator. One of '=', '!=', '<', '>', 'LIKE, 'IN', 'NOT IN'. |
|
45 | + */ |
|
46 | 46 | public function add_condition( $field, $value, $operator = '=' ) { |
47 | 47 | if ( is_array( $value ) ) { |
48 | 48 | $value = "('" . implode( "','", $value ) . "')"; |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | - * Implements PHP's magic __toString(). |
|
64 | - * |
|
65 | - * Function to convert the query to a string to pass to the SF API. |
|
66 | - * |
|
67 | - * @return string |
|
68 | - * SOQL query ready to be executed the SF API. |
|
69 | - */ |
|
63 | + * Implements PHP's magic __toString(). |
|
64 | + * |
|
65 | + * Function to convert the query to a string to pass to the SF API. |
|
66 | + * |
|
67 | + * @return string |
|
68 | + * SOQL query ready to be executed the SF API. |
|
69 | + */ |
|
70 | 70 | public function __toString() { |
71 | 71 | |
72 | 72 | $query = 'SELECT '; |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | protected $template; |
22 | 22 | |
23 | 23 | /** |
24 | - * Constructor which sets up the admin_notices hook for rendering |
|
25 | - * |
|
26 | - * @param mixed $condition |
|
27 | - * @param string $message |
|
28 | - * @param bool $dismissible |
|
29 | - * @param string $type |
|
30 | - * @param string $template |
|
31 | - * |
|
32 | - */ |
|
24 | + * Constructor which sets up the admin_notices hook for rendering |
|
25 | + * |
|
26 | + * @param mixed $condition |
|
27 | + * @param string $message |
|
28 | + * @param bool $dismissible |
|
29 | + * @param string $type |
|
30 | + * @param string $template |
|
31 | + * |
|
32 | + */ |
|
33 | 33 | public function __construct( $condition, $message, $dismissible = false, $type = '', $template = '' ) { |
34 | 34 | $this->condition = $condition; |
35 | 35 | $this->message = $message; |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | - * Render an admin notice |
|
46 | - * |
|
47 | - */ |
|
45 | + * Render an admin notice |
|
46 | + * |
|
47 | + */ |
|
48 | 48 | public function render() { |
49 | 49 | |
50 | 50 | // class for the notice to use |
@@ -22,9 +22,9 @@ |
||
22 | 22 | public $wsdl; |
23 | 23 | |
24 | 24 | /** |
25 | - * Constructor which loads the SOAP client |
|
26 | - * |
|
27 | - */ |
|
25 | + * Constructor which loads the SOAP client |
|
26 | + * |
|
27 | + */ |
|
28 | 28 | public function __construct( Object_Sync_Sf_Salesforce $sfapi, $wsdl = null ) { |
29 | 29 | if ( ! class_exists( 'SforceBaseClient' ) && file_exists( plugin_dir_path( __FILE__ ) . '../vendor/autoload.php' ) ) { |
30 | 30 | require_once plugin_dir_path( __FILE__ ) . '../vendor/developerforce/force.com-toolkit-for-php/soapclient/SforcePartnerClient.php'; |
@@ -17,31 +17,31 @@ discard block |
||
17 | 17 | public $response; |
18 | 18 | |
19 | 19 | /** |
20 | - * Constructor which initializes the Salesforce APIs. |
|
21 | - * |
|
22 | - * @param string $consumer_key |
|
23 | - * Salesforce key to connect to your Salesforce instance. |
|
24 | - * @param string $consumer_secret |
|
25 | - * Salesforce secret to connect to your Salesforce instance. |
|
26 | - * @param string $login_url |
|
27 | - * Login URL for Salesforce auth requests - differs for production and sandbox |
|
28 | - * @param string $callback_url |
|
29 | - * WordPress URL where Salesforce should send you after authentication |
|
30 | - * @param string $authorize_path |
|
31 | - * Oauth path that Salesforce wants |
|
32 | - * @param string $token_path |
|
33 | - * Path Salesforce uses to give you a token |
|
34 | - * @param string $rest_api_version |
|
35 | - * What version of the Salesforce REST API to use |
|
36 | - * @param object $wordpress |
|
37 | - * Object for doing things to WordPress - retrieving data, cache, etc. |
|
38 | - * @param string $slug |
|
39 | - * Slug for this plugin. Can be used for file including, especially |
|
40 | - * @param object $logging |
|
41 | - * Logging object for this plugin. |
|
42 | - * @param array $schedulable_classes |
|
43 | - * array of classes that can have scheduled tasks specific to them |
|
44 | - */ |
|
20 | + * Constructor which initializes the Salesforce APIs. |
|
21 | + * |
|
22 | + * @param string $consumer_key |
|
23 | + * Salesforce key to connect to your Salesforce instance. |
|
24 | + * @param string $consumer_secret |
|
25 | + * Salesforce secret to connect to your Salesforce instance. |
|
26 | + * @param string $login_url |
|
27 | + * Login URL for Salesforce auth requests - differs for production and sandbox |
|
28 | + * @param string $callback_url |
|
29 | + * WordPress URL where Salesforce should send you after authentication |
|
30 | + * @param string $authorize_path |
|
31 | + * Oauth path that Salesforce wants |
|
32 | + * @param string $token_path |
|
33 | + * Path Salesforce uses to give you a token |
|
34 | + * @param string $rest_api_version |
|
35 | + * What version of the Salesforce REST API to use |
|
36 | + * @param object $wordpress |
|
37 | + * Object for doing things to WordPress - retrieving data, cache, etc. |
|
38 | + * @param string $slug |
|
39 | + * Slug for this plugin. Can be used for file including, especially |
|
40 | + * @param object $logging |
|
41 | + * Logging object for this plugin. |
|
42 | + * @param array $schedulable_classes |
|
43 | + * array of classes that can have scheduled tasks specific to them |
|
44 | + */ |
|
45 | 45 | public function __construct( $consumer_key, $consumer_secret, $login_url, $callback_url, $authorize_path, $token_path, $rest_api_version, $wordpress, $slug, $logging, $schedulable_classes ) { |
46 | 46 | $this->consumer_key = $consumer_key; |
47 | 47 | $this->consumer_secret = $consumer_secret; |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
73 | - * Converts a 15-character case-sensitive Salesforce ID to 18-character |
|
74 | - * case-insensitive ID. If input is not 15-characters, return input unaltered. |
|
75 | - * |
|
76 | - * @param string $sf_id_15 |
|
77 | - * 15-character case-sensitive Salesforce ID |
|
78 | - * @return string |
|
79 | - * 18-character case-insensitive Salesforce ID |
|
80 | - */ |
|
73 | + * Converts a 15-character case-sensitive Salesforce ID to 18-character |
|
74 | + * case-insensitive ID. If input is not 15-characters, return input unaltered. |
|
75 | + * |
|
76 | + * @param string $sf_id_15 |
|
77 | + * 15-character case-sensitive Salesforce ID |
|
78 | + * @return string |
|
79 | + * 18-character case-insensitive Salesforce ID |
|
80 | + */ |
|
81 | 81 | public static function convert_id( $sf_id_15 ) { |
82 | 82 | if ( strlen( $sf_id_15 ) !== 15 ) { |
83 | 83 | return $sf_id_15; |
@@ -97,17 +97,17 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
100 | - * Given a Salesforce ID, return the corresponding SObject name. (Based on |
|
101 | - * keyPrefix from object definition, @see |
|
102 | - * https://developer.salesforce.com/forums/?id=906F0000000901ZIAQ ) |
|
103 | - * |
|
104 | - * @param string $sf_id |
|
105 | - * 15- or 18-character Salesforce ID |
|
106 | - * @return string |
|
107 | - * sObject name, e.g. "Account", "Contact", "my__Custom_Object__c" or FALSE |
|
108 | - * if no match could be found. |
|
109 | - * @throws Object_Sync_Sf_Exception |
|
110 | - */ |
|
100 | + * Given a Salesforce ID, return the corresponding SObject name. (Based on |
|
101 | + * keyPrefix from object definition, @see |
|
102 | + * https://developer.salesforce.com/forums/?id=906F0000000901ZIAQ ) |
|
103 | + * |
|
104 | + * @param string $sf_id |
|
105 | + * 15- or 18-character Salesforce ID |
|
106 | + * @return string |
|
107 | + * sObject name, e.g. "Account", "Contact", "my__Custom_Object__c" or FALSE |
|
108 | + * if no match could be found. |
|
109 | + * @throws Object_Sync_Sf_Exception |
|
110 | + */ |
|
111 | 111 | public function get_sobject_type( $sf_id ) { |
112 | 112 | $objects = $this->objects( |
113 | 113 | array( |
@@ -124,17 +124,17 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
127 | - * Determine if this SF instance is fully configured. |
|
128 | - * |
|
129 | - */ |
|
127 | + * Determine if this SF instance is fully configured. |
|
128 | + * |
|
129 | + */ |
|
130 | 130 | public function is_authorized() { |
131 | 131 | return ! empty( $this->consumer_key ) && ! empty( $this->consumer_secret ) && $this->get_refresh_token(); |
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | - * Get REST API versions available on this Salesforce organization |
|
136 | - * This is not an authenticated call, so it would not be a helpful test |
|
137 | - */ |
|
135 | + * Get REST API versions available on this Salesforce organization |
|
136 | + * This is not an authenticated call, so it would not be a helpful test |
|
137 | + */ |
|
138 | 138 | public function get_api_versions() { |
139 | 139 | $options = array( |
140 | 140 | 'authenticated' => false, |
@@ -144,26 +144,26 @@ discard block |
||
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | - * Make a call to the Salesforce REST API. |
|
148 | - * |
|
149 | - * @param string $path |
|
150 | - * Path to resource. |
|
151 | - * @param array $params |
|
152 | - * Parameters to provide. |
|
153 | - * @param string $method |
|
154 | - * Method to initiate the call, such as GET or POST. Defaults to GET. |
|
155 | - * @param array $options |
|
156 | - * Any method can supply options for the API call, and they'll be preserved as far as the curl request |
|
157 | - * They get merged with the class options |
|
158 | - * @param string $type |
|
159 | - * Type of call. Defaults to 'rest' - currently we don't support other types. |
|
160 | - * Other exammple in Drupal is 'apexrest' |
|
161 | - * |
|
162 | - * @return mixed |
|
163 | - * The requested response. |
|
164 | - * |
|
165 | - * @throws Object_Sync_Sf_Exception |
|
166 | - */ |
|
147 | + * Make a call to the Salesforce REST API. |
|
148 | + * |
|
149 | + * @param string $path |
|
150 | + * Path to resource. |
|
151 | + * @param array $params |
|
152 | + * Parameters to provide. |
|
153 | + * @param string $method |
|
154 | + * Method to initiate the call, such as GET or POST. Defaults to GET. |
|
155 | + * @param array $options |
|
156 | + * Any method can supply options for the API call, and they'll be preserved as far as the curl request |
|
157 | + * They get merged with the class options |
|
158 | + * @param string $type |
|
159 | + * Type of call. Defaults to 'rest' - currently we don't support other types. |
|
160 | + * Other exammple in Drupal is 'apexrest' |
|
161 | + * |
|
162 | + * @return mixed |
|
163 | + * The requested response. |
|
164 | + * |
|
165 | + * @throws Object_Sync_Sf_Exception |
|
166 | + */ |
|
167 | 167 | public function api_call( $path, $params = array(), $method = 'GET', $options = array(), $type = 'rest' ) { |
168 | 168 | if ( ! $this->get_access_token() ) { |
169 | 169 | $this->refresh_token(); |
@@ -214,25 +214,25 @@ discard block |
||
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
217 | - * Private helper to issue an SF API request. |
|
218 | - * This method is the only place where we read to or write from the cache |
|
219 | - * |
|
220 | - * @param string $path |
|
221 | - * Path to resource. |
|
222 | - * @param array $params |
|
223 | - * Parameters to provide. |
|
224 | - * @param string $method |
|
225 | - * Method to initiate the call, such as GET or POST. Defaults to GET. |
|
226 | - * @param array $options |
|
227 | - * This is the options array from the api_call method |
|
228 | - * This is where it gets merged with $this->options |
|
229 | - * @param string $type |
|
230 | - * Type of call. Defaults to 'rest' - currently we don't support other types |
|
231 | - * Other exammple in Drupal is 'apexrest' |
|
232 | - * |
|
233 | - * @return array |
|
234 | - * The requested data. |
|
235 | - */ |
|
217 | + * Private helper to issue an SF API request. |
|
218 | + * This method is the only place where we read to or write from the cache |
|
219 | + * |
|
220 | + * @param string $path |
|
221 | + * Path to resource. |
|
222 | + * @param array $params |
|
223 | + * Parameters to provide. |
|
224 | + * @param string $method |
|
225 | + * Method to initiate the call, such as GET or POST. Defaults to GET. |
|
226 | + * @param array $options |
|
227 | + * This is the options array from the api_call method |
|
228 | + * This is where it gets merged with $this->options |
|
229 | + * @param string $type |
|
230 | + * Type of call. Defaults to 'rest' - currently we don't support other types |
|
231 | + * Other exammple in Drupal is 'apexrest' |
|
232 | + * |
|
233 | + * @return array |
|
234 | + * The requested data. |
|
235 | + */ |
|
236 | 236 | protected function api_http_request( $path, $params, $method, $options = array(), $type = 'rest' ) { |
237 | 237 | $options = array_merge( $this->options, $options ); // this will override a value in $this->options with the one in $options if there is a matching key |
238 | 238 | $url = $this->get_api_endpoint( $type ) . $path; |
@@ -310,22 +310,22 @@ discard block |
||
310 | 310 | } |
311 | 311 | |
312 | 312 | /** |
313 | - * Make the HTTP request. Wrapper around curl(). |
|
314 | - * |
|
315 | - * @param string $url |
|
316 | - * Path to make request from. |
|
317 | - * @param array $data |
|
318 | - * The request body. |
|
319 | - * @param array $headers |
|
320 | - * Request headers to send as name => value. |
|
321 | - * @param string $method |
|
322 | - * Method to initiate the call, such as GET or POST. Defaults to GET. |
|
323 | - * @param array $options |
|
324 | - * This is the options array from the api_http_request method |
|
325 | - * |
|
326 | - * @return array |
|
327 | - * Salesforce response object. |
|
328 | - */ |
|
313 | + * Make the HTTP request. Wrapper around curl(). |
|
314 | + * |
|
315 | + * @param string $url |
|
316 | + * Path to make request from. |
|
317 | + * @param array $data |
|
318 | + * The request body. |
|
319 | + * @param array $headers |
|
320 | + * Request headers to send as name => value. |
|
321 | + * @param string $method |
|
322 | + * Method to initiate the call, such as GET or POST. Defaults to GET. |
|
323 | + * @param array $options |
|
324 | + * This is the options array from the api_http_request method |
|
325 | + * |
|
326 | + * @return array |
|
327 | + * Salesforce response object. |
|
328 | + */ |
|
329 | 329 | protected function http_request( $url, $data, $headers = array(), $method = 'GET', $options = array() ) { |
330 | 330 | // Build the request, including path and headers. Internal use. |
331 | 331 | |
@@ -460,14 +460,14 @@ discard block |
||
460 | 460 | } |
461 | 461 | |
462 | 462 | /** |
463 | - * Get the API end point for a given type of the API. |
|
464 | - * |
|
465 | - * @param string $api_type |
|
466 | - * E.g., rest, partner, enterprise. |
|
467 | - * |
|
468 | - * @return string |
|
469 | - * Complete URL endpoint for API access. |
|
470 | - */ |
|
463 | + * Get the API end point for a given type of the API. |
|
464 | + * |
|
465 | + * @param string $api_type |
|
466 | + * E.g., rest, partner, enterprise. |
|
467 | + * |
|
468 | + * @return string |
|
469 | + * Complete URL endpoint for API access. |
|
470 | + */ |
|
471 | 471 | public function get_api_endpoint( $api_type = 'rest' ) { |
472 | 472 | // Special handling for apexrest, since it's not in the identity object. |
473 | 473 | if ( 'apexrest' === $api_type ) { |
@@ -483,67 +483,67 @@ discard block |
||
483 | 483 | } |
484 | 484 | |
485 | 485 | /** |
486 | - * Get the SF instance URL. Useful for linking to objects. |
|
487 | - */ |
|
486 | + * Get the SF instance URL. Useful for linking to objects. |
|
487 | + */ |
|
488 | 488 | public function get_instance_url() { |
489 | 489 | return get_option( 'object_sync_for_salesforce_instance_url', '' ); |
490 | 490 | } |
491 | 491 | |
492 | 492 | /** |
493 | - * Set the SF instanc URL. |
|
494 | - * |
|
495 | - * @param string $url |
|
496 | - * URL to set. |
|
497 | - */ |
|
493 | + * Set the SF instanc URL. |
|
494 | + * |
|
495 | + * @param string $url |
|
496 | + * URL to set. |
|
497 | + */ |
|
498 | 498 | protected function set_instance_url( $url ) { |
499 | 499 | update_option( 'object_sync_for_salesforce_instance_url', $url ); |
500 | 500 | } |
501 | 501 | |
502 | 502 | /** |
503 | - * Get the access token. |
|
504 | - */ |
|
503 | + * Get the access token. |
|
504 | + */ |
|
505 | 505 | public function get_access_token() { |
506 | 506 | return get_option( 'object_sync_for_salesforce_access_token', '' ); |
507 | 507 | } |
508 | 508 | |
509 | 509 | /** |
510 | - * Set the access token. |
|
511 | - * |
|
512 | - * It is stored in session. |
|
513 | - * |
|
514 | - * @param string $token |
|
515 | - * Access token from Salesforce. |
|
516 | - */ |
|
510 | + * Set the access token. |
|
511 | + * |
|
512 | + * It is stored in session. |
|
513 | + * |
|
514 | + * @param string $token |
|
515 | + * Access token from Salesforce. |
|
516 | + */ |
|
517 | 517 | protected function set_access_token( $token ) { |
518 | 518 | update_option( 'object_sync_for_salesforce_access_token', $token ); |
519 | 519 | } |
520 | 520 | |
521 | 521 | /** |
522 | - * Get refresh token. |
|
523 | - */ |
|
522 | + * Get refresh token. |
|
523 | + */ |
|
524 | 524 | protected function get_refresh_token() { |
525 | 525 | return get_option( 'object_sync_for_salesforce_refresh_token', '' ); |
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
529 | - * Set refresh token. |
|
530 | - * |
|
531 | - * @param string $token |
|
532 | - * Refresh token from Salesforce. |
|
533 | - */ |
|
529 | + * Set refresh token. |
|
530 | + * |
|
531 | + * @param string $token |
|
532 | + * Refresh token from Salesforce. |
|
533 | + */ |
|
534 | 534 | protected function set_refresh_token( $token ) { |
535 | 535 | update_option( 'object_sync_for_salesforce_refresh_token', $token ); |
536 | 536 | } |
537 | 537 | |
538 | 538 | /** |
539 | - * Refresh access token based on the refresh token. Updates session variable. |
|
540 | - * |
|
541 | - * todo: figure out how to do this as part of the schedule class |
|
542 | - * this is a scheduleable class and so we could add a method from this class to run every 24 hours, but it's unclear to me that we need it. salesforce seems to refresh itself as it needs to. |
|
543 | - * but it could be a performance boost to do it at scheduleable intervals instead. |
|
544 | - * |
|
545 | - * @throws Object_Sync_Sf_Exception |
|
546 | - */ |
|
539 | + * Refresh access token based on the refresh token. Updates session variable. |
|
540 | + * |
|
541 | + * todo: figure out how to do this as part of the schedule class |
|
542 | + * this is a scheduleable class and so we could add a method from this class to run every 24 hours, but it's unclear to me that we need it. salesforce seems to refresh itself as it needs to. |
|
543 | + * but it could be a performance boost to do it at scheduleable intervals instead. |
|
544 | + * |
|
545 | + * @throws Object_Sync_Sf_Exception |
|
546 | + */ |
|
547 | 547 | protected function refresh_token() { |
548 | 548 | $refresh_token = $this->get_refresh_token(); |
549 | 549 | if ( empty( $refresh_token ) ) { |
@@ -590,13 +590,13 @@ discard block |
||
590 | 590 | } |
591 | 591 | |
592 | 592 | /** |
593 | - * Retrieve and store the Salesforce identity given an ID url. |
|
594 | - * |
|
595 | - * @param string $id |
|
596 | - * Identity URL. |
|
597 | - * |
|
598 | - * @throws Object_Sync_Sf_Exception |
|
599 | - */ |
|
593 | + * Retrieve and store the Salesforce identity given an ID url. |
|
594 | + * |
|
595 | + * @param string $id |
|
596 | + * Identity URL. |
|
597 | + * |
|
598 | + * @throws Object_Sync_Sf_Exception |
|
599 | + */ |
|
600 | 600 | protected function set_identity( $id ) { |
601 | 601 | $headers = array( |
602 | 602 | 'Authorization' => 'Authorization: OAuth ' . $this->get_access_token(), |
@@ -612,18 +612,18 @@ discard block |
||
612 | 612 | } |
613 | 613 | |
614 | 614 | /** |
615 | - * Return the Salesforce identity, which is stored in a variable. |
|
616 | - * |
|
617 | - * @return array |
|
618 | - * Returns FALSE if no identity has been stored. |
|
619 | - */ |
|
615 | + * Return the Salesforce identity, which is stored in a variable. |
|
616 | + * |
|
617 | + * @return array |
|
618 | + * Returns FALSE if no identity has been stored. |
|
619 | + */ |
|
620 | 620 | public function get_identity() { |
621 | 621 | return get_option( 'object_sync_for_salesforce_identity', false ); |
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
625 | - * OAuth step 1: Redirect to Salesforce and request and authorization code. |
|
626 | - */ |
|
625 | + * OAuth step 1: Redirect to Salesforce and request and authorization code. |
|
626 | + */ |
|
627 | 627 | public function get_authorization_code() { |
628 | 628 | $url = add_query_arg( |
629 | 629 | array( |
@@ -637,11 +637,11 @@ discard block |
||
637 | 637 | } |
638 | 638 | |
639 | 639 | /** |
640 | - * OAuth step 2: Exchange an authorization code for an access token. |
|
641 | - * |
|
642 | - * @param string $code |
|
643 | - * Code from Salesforce. |
|
644 | - */ |
|
640 | + * OAuth step 2: Exchange an authorization code for an access token. |
|
641 | + * |
|
642 | + * @param string $code |
|
643 | + * Code from Salesforce. |
|
644 | + */ |
|
645 | 645 | public function request_token( $code ) { |
646 | 646 | $data = array( |
647 | 647 | 'code' => $code, |
@@ -686,22 +686,22 @@ discard block |
||
686 | 686 | /* Core API calls */ |
687 | 687 | |
688 | 688 | /** |
689 | - * Available objects and their metadata for your organization's data. |
|
690 | - * |
|
691 | - * @param array $conditions |
|
692 | - * Associative array of filters to apply to the returned objects. Filters |
|
693 | - * are applied after the list is returned from Salesforce. |
|
694 | - * @param bool $reset |
|
695 | - * Whether to reset the cache and retrieve a fresh version from Salesforce. |
|
696 | - * |
|
697 | - * @return array |
|
698 | - * Available objects and metadata. |
|
699 | - * |
|
700 | - * part of core API calls. this call does require authentication, and the basic url it becomes is like this: |
|
701 | - * https://instance.salesforce.com/services/data/v#.0/sobjects |
|
702 | - * |
|
703 | - * updateable is really how the api spells it |
|
704 | - */ |
|
689 | + * Available objects and their metadata for your organization's data. |
|
690 | + * |
|
691 | + * @param array $conditions |
|
692 | + * Associative array of filters to apply to the returned objects. Filters |
|
693 | + * are applied after the list is returned from Salesforce. |
|
694 | + * @param bool $reset |
|
695 | + * Whether to reset the cache and retrieve a fresh version from Salesforce. |
|
696 | + * |
|
697 | + * @return array |
|
698 | + * Available objects and metadata. |
|
699 | + * |
|
700 | + * part of core API calls. this call does require authentication, and the basic url it becomes is like this: |
|
701 | + * https://instance.salesforce.com/services/data/v#.0/sobjects |
|
702 | + * |
|
703 | + * updateable is really how the api spells it |
|
704 | + */ |
|
705 | 705 | public function objects( |
706 | 706 | $conditions = array( |
707 | 707 | 'updateable' => true, |
@@ -731,22 +731,22 @@ discard block |
||
731 | 731 | } |
732 | 732 | |
733 | 733 | /** |
734 | - * Use SOQL to get objects based on query string. |
|
735 | - * |
|
736 | - * @param string $query |
|
737 | - * The SOQL query. |
|
738 | - * @param array $options |
|
739 | - * Allow for the query to have options based on what the user needs from it, ie caching, read/write, etc. |
|
740 | - * @param boolean $all |
|
741 | - * Whether this should get all results for the query |
|
742 | - * @param boolean $explain |
|
743 | - * If set, Salesforce will return feedback on the query performance |
|
744 | - * |
|
745 | - * @return array |
|
746 | - * Array of Salesforce objects that match the query. |
|
747 | - * |
|
748 | - * part of core API calls |
|
749 | - */ |
|
734 | + * Use SOQL to get objects based on query string. |
|
735 | + * |
|
736 | + * @param string $query |
|
737 | + * The SOQL query. |
|
738 | + * @param array $options |
|
739 | + * Allow for the query to have options based on what the user needs from it, ie caching, read/write, etc. |
|
740 | + * @param boolean $all |
|
741 | + * Whether this should get all results for the query |
|
742 | + * @param boolean $explain |
|
743 | + * If set, Salesforce will return feedback on the query performance |
|
744 | + * |
|
745 | + * @return array |
|
746 | + * Array of Salesforce objects that match the query. |
|
747 | + * |
|
748 | + * part of core API calls |
|
749 | + */ |
|
750 | 750 | public function query( $query, $options = array(), $all = false, $explain = false ) { |
751 | 751 | $search_data = [ |
752 | 752 | 'q' => (string) $query, |
@@ -766,19 +766,19 @@ discard block |
||
766 | 766 | } |
767 | 767 | |
768 | 768 | /** |
769 | - * Retrieve all the metadata for an object. |
|
770 | - * |
|
771 | - * @param string $name |
|
772 | - * Object type name, E.g., Contact, Account, etc. |
|
773 | - * @param bool $reset |
|
774 | - * Whether to reset the cache and retrieve a fresh version from Salesforce. |
|
775 | - * |
|
776 | - * @return array |
|
777 | - * All the metadata for an object, including information about each field, |
|
778 | - * URLs, and child relationships. |
|
779 | - * |
|
780 | - * part of core API calls |
|
781 | - */ |
|
769 | + * Retrieve all the metadata for an object. |
|
770 | + * |
|
771 | + * @param string $name |
|
772 | + * Object type name, E.g., Contact, Account, etc. |
|
773 | + * @param bool $reset |
|
774 | + * Whether to reset the cache and retrieve a fresh version from Salesforce. |
|
775 | + * |
|
776 | + * @return array |
|
777 | + * All the metadata for an object, including information about each field, |
|
778 | + * URLs, and child relationships. |
|
779 | + * |
|
780 | + * part of core API calls |
|
781 | + */ |
|
782 | 782 | public function object_describe( $name, $reset = false ) { |
783 | 783 | if ( empty( $name ) ) { |
784 | 784 | return array(); |
@@ -806,26 +806,26 @@ discard block |
||
806 | 806 | } |
807 | 807 | |
808 | 808 | /** |
809 | - * Create a new object of the given type. |
|
810 | - * |
|
811 | - * @param string $name |
|
812 | - * Object type name, E.g., Contact, Account, etc. |
|
813 | - * @param array $params |
|
814 | - * Values of the fields to set for the object. |
|
815 | - * |
|
816 | - * @return array |
|
817 | - * json: {"id":"00190000001pPvHAAU","success":true,"errors":[]} |
|
818 | - * code: 201 |
|
819 | - * data: |
|
820 | - * "id" : "00190000001pPvHAAU", |
|
821 | - * "success" : true |
|
822 | - * "errors" : [ ], |
|
823 | - * from_cache: |
|
824 | - * cached: |
|
825 | - * is_redo: |
|
826 | - * |
|
827 | - * part of core API calls |
|
828 | - */ |
|
809 | + * Create a new object of the given type. |
|
810 | + * |
|
811 | + * @param string $name |
|
812 | + * Object type name, E.g., Contact, Account, etc. |
|
813 | + * @param array $params |
|
814 | + * Values of the fields to set for the object. |
|
815 | + * |
|
816 | + * @return array |
|
817 | + * json: {"id":"00190000001pPvHAAU","success":true,"errors":[]} |
|
818 | + * code: 201 |
|
819 | + * data: |
|
820 | + * "id" : "00190000001pPvHAAU", |
|
821 | + * "success" : true |
|
822 | + * "errors" : [ ], |
|
823 | + * from_cache: |
|
824 | + * cached: |
|
825 | + * is_redo: |
|
826 | + * |
|
827 | + * part of core API calls |
|
828 | + */ |
|
829 | 829 | public function object_create( $name, $params ) { |
830 | 830 | $options = array( |
831 | 831 | 'type' => 'write', |
@@ -835,34 +835,34 @@ discard block |
||
835 | 835 | } |
836 | 836 | |
837 | 837 | /** |
838 | - * Create new records or update existing records. |
|
839 | - * |
|
840 | - * The new records or updated records are based on the value of the specified |
|
841 | - * field. If the value is not unique, REST API returns a 300 response with |
|
842 | - * the list of matching records. |
|
843 | - * |
|
844 | - * @param string $name |
|
845 | - * Object type name, E.g., Contact, Account. |
|
846 | - * @param string $key |
|
847 | - * The field to check if this record should be created or updated. |
|
848 | - * @param string $value |
|
849 | - * The value for this record of the field specified for $key. |
|
850 | - * @param array $params |
|
851 | - * Values of the fields to set for the object. |
|
852 | - * |
|
853 | - * @return array |
|
854 | - * json: {"id":"00190000001pPvHAAU","success":true,"errors":[]} |
|
855 | - * code: 201 |
|
856 | - * data: |
|
857 | - * "id" : "00190000001pPvHAAU", |
|
858 | - * "success" : true |
|
859 | - * "errors" : [ ], |
|
860 | - * from_cache: |
|
861 | - * cached: |
|
862 | - * is_redo: |
|
863 | - * |
|
864 | - * part of core API calls |
|
865 | - */ |
|
838 | + * Create new records or update existing records. |
|
839 | + * |
|
840 | + * The new records or updated records are based on the value of the specified |
|
841 | + * field. If the value is not unique, REST API returns a 300 response with |
|
842 | + * the list of matching records. |
|
843 | + * |
|
844 | + * @param string $name |
|
845 | + * Object type name, E.g., Contact, Account. |
|
846 | + * @param string $key |
|
847 | + * The field to check if this record should be created or updated. |
|
848 | + * @param string $value |
|
849 | + * The value for this record of the field specified for $key. |
|
850 | + * @param array $params |
|
851 | + * Values of the fields to set for the object. |
|
852 | + * |
|
853 | + * @return array |
|
854 | + * json: {"id":"00190000001pPvHAAU","success":true,"errors":[]} |
|
855 | + * code: 201 |
|
856 | + * data: |
|
857 | + * "id" : "00190000001pPvHAAU", |
|
858 | + * "success" : true |
|
859 | + * "errors" : [ ], |
|
860 | + * from_cache: |
|
861 | + * cached: |
|
862 | + * is_redo: |
|
863 | + * |
|
864 | + * part of core API calls |
|
865 | + */ |
|
866 | 866 | public function object_upsert( $name, $key, $value, $params ) { |
867 | 867 | $options = array( |
868 | 868 | 'type' => 'write', |
@@ -884,27 +884,27 @@ discard block |
||
884 | 884 | } |
885 | 885 | |
886 | 886 | /** |
887 | - * Update an existing object. |
|
888 | - * |
|
889 | - * @param string $name |
|
890 | - * Object type name, E.g., Contact, Account. |
|
891 | - * @param string $id |
|
892 | - * Salesforce id of the object. |
|
893 | - * @param array $params |
|
894 | - * Values of the fields to set for the object. |
|
895 | - * |
|
896 | - * part of core API calls |
|
897 | - * |
|
898 | - * @return array |
|
899 | - * json: {"success":true,"body":""} |
|
900 | - * code: 204 |
|
901 | - * data: |
|
887 | + * Update an existing object. |
|
888 | + * |
|
889 | + * @param string $name |
|
890 | + * Object type name, E.g., Contact, Account. |
|
891 | + * @param string $id |
|
892 | + * Salesforce id of the object. |
|
893 | + * @param array $params |
|
894 | + * Values of the fields to set for the object. |
|
895 | + * |
|
896 | + * part of core API calls |
|
897 | + * |
|
898 | + * @return array |
|
899 | + * json: {"success":true,"body":""} |
|
900 | + * code: 204 |
|
901 | + * data: |
|
902 | 902 | success: 1 |
903 | 903 | body: |
904 | - * from_cache: |
|
905 | - * cached: |
|
906 | - * is_redo: |
|
907 | - */ |
|
904 | + * from_cache: |
|
905 | + * cached: |
|
906 | + * is_redo: |
|
907 | + */ |
|
908 | 908 | public function object_update( $name, $id, $params ) { |
909 | 909 | $options = array( |
910 | 910 | 'type' => 'write', |
@@ -914,62 +914,62 @@ discard block |
||
914 | 914 | } |
915 | 915 | |
916 | 916 | /** |
917 | - * Return a full loaded Salesforce object. |
|
918 | - * |
|
919 | - * @param string $name |
|
920 | - * Object type name, E.g., Contact, Account. |
|
921 | - * @param string $id |
|
922 | - * Salesforce id of the object. |
|
923 | - * |
|
924 | - * @return object |
|
925 | - * Object of the requested Salesforce object. |
|
926 | - * |
|
927 | - * part of core API calls |
|
928 | - */ |
|
917 | + * Return a full loaded Salesforce object. |
|
918 | + * |
|
919 | + * @param string $name |
|
920 | + * Object type name, E.g., Contact, Account. |
|
921 | + * @param string $id |
|
922 | + * Salesforce id of the object. |
|
923 | + * |
|
924 | + * @return object |
|
925 | + * Object of the requested Salesforce object. |
|
926 | + * |
|
927 | + * part of core API calls |
|
928 | + */ |
|
929 | 929 | public function object_read( $name, $id ) { |
930 | 930 | return $this->api_call( "sobjects/{$name}/{$id}", array(), 'GET' ); |
931 | 931 | } |
932 | 932 | |
933 | 933 | /** |
934 | - * Make a call to the Analytics API |
|
935 | - * |
|
936 | - * @param string $name |
|
937 | - * Object type name, E.g., Report |
|
938 | - * @param string $id |
|
939 | - * Salesforce id of the object. |
|
940 | - * @param string $route |
|
941 | - * What comes after the ID? E.g. instances, ?includeDetails=True |
|
942 | - * @param array $params |
|
943 | - * Params to put with the request |
|
944 | - * @param string $method |
|
945 | - * GET or POST |
|
946 | - * |
|
947 | - * @return object |
|
948 | - * Object of the requested Salesforce object. |
|
949 | - * |
|
950 | - * part of core API calls |
|
951 | - */ |
|
934 | + * Make a call to the Analytics API |
|
935 | + * |
|
936 | + * @param string $name |
|
937 | + * Object type name, E.g., Report |
|
938 | + * @param string $id |
|
939 | + * Salesforce id of the object. |
|
940 | + * @param string $route |
|
941 | + * What comes after the ID? E.g. instances, ?includeDetails=True |
|
942 | + * @param array $params |
|
943 | + * Params to put with the request |
|
944 | + * @param string $method |
|
945 | + * GET or POST |
|
946 | + * |
|
947 | + * @return object |
|
948 | + * Object of the requested Salesforce object. |
|
949 | + * |
|
950 | + * part of core API calls |
|
951 | + */ |
|
952 | 952 | public function analytics_api( $name, $id, $route = '', $params = array(), $method = 'GET' ) { |
953 | 953 | return $this->api_call( "analytics/{$name}/{$id}/{$route}", $params, $method ); |
954 | 954 | } |
955 | 955 | |
956 | 956 | /** |
957 | - * Run a specific Analytics report |
|
958 | - * |
|
959 | - * @param string $id |
|
960 | - * Salesforce id of the object. |
|
961 | - * @param bool $async |
|
962 | - * Whether the report is asynchronous |
|
963 | - * @param array $params |
|
964 | - * Params to put with the request |
|
965 | - * @param string $method |
|
966 | - * GET or POST |
|
967 | - * |
|
968 | - * @return object |
|
969 | - * Object of the requested Salesforce object. |
|
970 | - * |
|
971 | - * part of core API calls |
|
972 | - */ |
|
957 | + * Run a specific Analytics report |
|
958 | + * |
|
959 | + * @param string $id |
|
960 | + * Salesforce id of the object. |
|
961 | + * @param bool $async |
|
962 | + * Whether the report is asynchronous |
|
963 | + * @param array $params |
|
964 | + * Params to put with the request |
|
965 | + * @param string $method |
|
966 | + * GET or POST |
|
967 | + * |
|
968 | + * @return object |
|
969 | + * Object of the requested Salesforce object. |
|
970 | + * |
|
971 | + * part of core API calls |
|
972 | + */ |
|
973 | 973 | public function run_analytics_report( $id, $async = true, $clear_cache = false, $params = array(), $method = 'GET', $report_cache_expiration = '', $cache_instance = true, $instance_cache_expiration = '' ) { |
974 | 974 | |
975 | 975 | $id = $this->convert_id( $id ); |
@@ -1055,36 +1055,36 @@ discard block |
||
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | /** |
1058 | - * Return a full loaded Salesforce object from External ID. |
|
1059 | - * |
|
1060 | - * @param string $name |
|
1061 | - * Object type name, E.g., Contact, Account. |
|
1062 | - * @param string $field |
|
1063 | - * Salesforce external id field name. |
|
1064 | - * @param string $value |
|
1065 | - * Value of external id. |
|
1066 | - * |
|
1067 | - * @return object |
|
1068 | - * Object of the requested Salesforce object. |
|
1069 | - * |
|
1070 | - * part of core API calls |
|
1071 | - */ |
|
1058 | + * Return a full loaded Salesforce object from External ID. |
|
1059 | + * |
|
1060 | + * @param string $name |
|
1061 | + * Object type name, E.g., Contact, Account. |
|
1062 | + * @param string $field |
|
1063 | + * Salesforce external id field name. |
|
1064 | + * @param string $value |
|
1065 | + * Value of external id. |
|
1066 | + * |
|
1067 | + * @return object |
|
1068 | + * Object of the requested Salesforce object. |
|
1069 | + * |
|
1070 | + * part of core API calls |
|
1071 | + */ |
|
1072 | 1072 | public function object_readby_external_id( $name, $field, $value ) { |
1073 | 1073 | return $this->api_call( "sobjects/{$name}/{$field}/{$value}" ); |
1074 | 1074 | } |
1075 | 1075 | |
1076 | 1076 | /** |
1077 | - * Delete a Salesforce object. |
|
1078 | - * |
|
1079 | - * @param string $name |
|
1080 | - * Object type name, E.g., Contact, Account. |
|
1081 | - * @param string $id |
|
1082 | - * Salesforce id of the object. |
|
1083 | - * |
|
1084 | - * @return array |
|
1085 | - * |
|
1086 | - * part of core API calls |
|
1087 | - */ |
|
1077 | + * Delete a Salesforce object. |
|
1078 | + * |
|
1079 | + * @param string $name |
|
1080 | + * Object type name, E.g., Contact, Account. |
|
1081 | + * @param string $id |
|
1082 | + * Salesforce id of the object. |
|
1083 | + * |
|
1084 | + * @return array |
|
1085 | + * |
|
1086 | + * part of core API calls |
|
1087 | + */ |
|
1088 | 1088 | public function object_delete( $name, $id ) { |
1089 | 1089 | $options = array( |
1090 | 1090 | 'type' => 'write', |
@@ -1094,17 +1094,17 @@ discard block |
||
1094 | 1094 | } |
1095 | 1095 | |
1096 | 1096 | /** |
1097 | - * Retrieves the list of individual objects that have been deleted within the |
|
1098 | - * given timespan for a specified object type. |
|
1099 | - * |
|
1100 | - * @param string $type |
|
1101 | - * Object type name, E.g., Contact, Account. |
|
1102 | - * @param string $startDate |
|
1103 | - * Start date to check for deleted objects (in ISO 8601 format). |
|
1104 | - * @param string $endDate |
|
1105 | - * End date to check for deleted objects (in ISO 8601 format). |
|
1106 | - * @return GetDeletedResult |
|
1107 | - */ |
|
1097 | + * Retrieves the list of individual objects that have been deleted within the |
|
1098 | + * given timespan for a specified object type. |
|
1099 | + * |
|
1100 | + * @param string $type |
|
1101 | + * Object type name, E.g., Contact, Account. |
|
1102 | + * @param string $startDate |
|
1103 | + * Start date to check for deleted objects (in ISO 8601 format). |
|
1104 | + * @param string $endDate |
|
1105 | + * End date to check for deleted objects (in ISO 8601 format). |
|
1106 | + * @return GetDeletedResult |
|
1107 | + */ |
|
1108 | 1108 | public function get_deleted( $type, $start_date, $end_date ) { |
1109 | 1109 | $options = array( |
1110 | 1110 | 'cache' => false, |
@@ -1114,13 +1114,13 @@ discard block |
||
1114 | 1114 | |
1115 | 1115 | |
1116 | 1116 | /** |
1117 | - * Return a list of available resources for the configured API version. |
|
1118 | - * |
|
1119 | - * @return array |
|
1120 | - * Associative array keyed by name with a URI value. |
|
1121 | - * |
|
1122 | - * part of core API calls |
|
1123 | - */ |
|
1117 | + * Return a list of available resources for the configured API version. |
|
1118 | + * |
|
1119 | + * @return array |
|
1120 | + * Associative array keyed by name with a URI value. |
|
1121 | + * |
|
1122 | + * part of core API calls |
|
1123 | + */ |
|
1124 | 1124 | public function list_resources() { |
1125 | 1125 | $resources = $this->api_call( '' ); |
1126 | 1126 | foreach ( $resources as $key => $path ) { |
@@ -1130,31 +1130,31 @@ discard block |
||
1130 | 1130 | } |
1131 | 1131 | |
1132 | 1132 | /** |
1133 | - * Return a list of SFIDs for the given object, which have been created or |
|
1134 | - * updated in the given timeframe. |
|
1135 | - * |
|
1136 | - * @param string $type |
|
1137 | - * Object type name, E.g., Contact, Account. |
|
1138 | - * |
|
1139 | - * @param int $start |
|
1140 | - * unix timestamp for older timeframe for updates. |
|
1141 | - * Defaults to "-29 days" if empty. |
|
1142 | - * |
|
1143 | - * @param int $end |
|
1144 | - * unix timestamp for end of timeframe for updates. |
|
1145 | - * Defaults to now if empty |
|
1146 | - * |
|
1147 | - * @return array |
|
1148 | - * return array has 2 indexes: |
|
1149 | - * "ids": a list of SFIDs of those records which have been created or |
|
1150 | - * updated in the given timeframe. |
|
1151 | - * "latestDateCovered": ISO 8601 format timestamp (UTC) of the last date |
|
1152 | - * covered in the request. |
|
1153 | - * |
|
1154 | - * @see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_getupdated.htm |
|
1155 | - * |
|
1156 | - * part of core API calls |
|
1157 | - */ |
|
1133 | + * Return a list of SFIDs for the given object, which have been created or |
|
1134 | + * updated in the given timeframe. |
|
1135 | + * |
|
1136 | + * @param string $type |
|
1137 | + * Object type name, E.g., Contact, Account. |
|
1138 | + * |
|
1139 | + * @param int $start |
|
1140 | + * unix timestamp for older timeframe for updates. |
|
1141 | + * Defaults to "-29 days" if empty. |
|
1142 | + * |
|
1143 | + * @param int $end |
|
1144 | + * unix timestamp for end of timeframe for updates. |
|
1145 | + * Defaults to now if empty |
|
1146 | + * |
|
1147 | + * @return array |
|
1148 | + * return array has 2 indexes: |
|
1149 | + * "ids": a list of SFIDs of those records which have been created or |
|
1150 | + * updated in the given timeframe. |
|
1151 | + * "latestDateCovered": ISO 8601 format timestamp (UTC) of the last date |
|
1152 | + * covered in the request. |
|
1153 | + * |
|
1154 | + * @see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_getupdated.htm |
|
1155 | + * |
|
1156 | + * part of core API calls |
|
1157 | + */ |
|
1158 | 1158 | public function get_updated( $type, $start = null, $end = null ) { |
1159 | 1159 | if ( empty( $start ) ) { |
1160 | 1160 | $start = strtotime( '-29 days' ); |
@@ -1173,19 +1173,19 @@ discard block |
||
1173 | 1173 | } |
1174 | 1174 | |
1175 | 1175 | /** |
1176 | - * Given a DeveloperName and SObject Name, return the SFID of the |
|
1177 | - * corresponding RecordType. DeveloperName doesn't change between Salesforce |
|
1178 | - * environments, so it's safer to rely on compared to SFID. |
|
1179 | - * |
|
1180 | - * @param string $name |
|
1181 | - * Object type name, E.g., Contact, Account. |
|
1182 | - * |
|
1183 | - * @param string $devname |
|
1184 | - * RecordType DeveloperName, e.g. Donation, Membership, etc. |
|
1185 | - * |
|
1186 | - * @return string SFID |
|
1187 | - * The Salesforce ID of the given Record Type, or null. |
|
1188 | - */ |
|
1176 | + * Given a DeveloperName and SObject Name, return the SFID of the |
|
1177 | + * corresponding RecordType. DeveloperName doesn't change between Salesforce |
|
1178 | + * environments, so it's safer to rely on compared to SFID. |
|
1179 | + * |
|
1180 | + * @param string $name |
|
1181 | + * Object type name, E.g., Contact, Account. |
|
1182 | + * |
|
1183 | + * @param string $devname |
|
1184 | + * RecordType DeveloperName, e.g. Donation, Membership, etc. |
|
1185 | + * |
|
1186 | + * @return string SFID |
|
1187 | + * The Salesforce ID of the given Record Type, or null. |
|
1188 | + */ |
|
1189 | 1189 | |
1190 | 1190 | public function get_record_type_id_by_developer_name( $name, $devname, $reset = false ) { |
1191 | 1191 | |
@@ -1213,10 +1213,10 @@ discard block |
||
1213 | 1213 | } |
1214 | 1214 | |
1215 | 1215 | /** |
1216 | - * If there is a WordPress setting for how long to keep the cache, return it and set the object property |
|
1217 | - * Otherwise, return seconds in 24 hours |
|
1218 | - * |
|
1219 | - */ |
|
1216 | + * If there is a WordPress setting for how long to keep the cache, return it and set the object property |
|
1217 | + * Otherwise, return seconds in 24 hours |
|
1218 | + * |
|
1219 | + */ |
|
1220 | 1220 | private function cache_expiration() { |
1221 | 1221 | $cache_expiration = $this->wordpress->cache_expiration( 'object_sync_for_salesforce_cache_expiration', 86400 ); |
1222 | 1222 | return $cache_expiration; |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | * Connect method to www.salesforce.com |
99 | 99 | * |
100 | 100 | * @param string $wsdl Salesforce.com Partner WSDL |
101 | - * @param object $proxy (optional) proxy settings with properties host, port, |
|
102 | - * login and password |
|
103 | - * @param array $soap_options (optional) Additional options to send to the |
|
104 | - * SoapClient constructor. @see |
|
105 | - * http://php.net/manual/en/soapclient.soapclient.php |
|
101 | + * @param object $proxy (optional) proxy settings with properties host, port, |
|
102 | + * login and password |
|
103 | + * @param array $soap_options (optional) Additional options to send to the |
|
104 | + * SoapClient constructor. @see |
|
105 | + * http://php.net/manual/en/soapclient.soapclient.php |
|
106 | 106 | */ |
107 | 107 | public function createConnection($wsdl, $proxy=null, $soap_options=array()) { |
108 | 108 | $phpversion = substr(phpversion(), 0, strpos(phpversion(), '-')); |
@@ -122,12 +122,12 @@ discard block |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | if ($proxy != null) { |
125 | - $proxySettings = array(); |
|
126 | - $proxySettings['proxy_host'] = $proxy->host; |
|
127 | - $proxySettings['proxy_port'] = $proxy->port; // Use an integer, not a string |
|
128 | - $proxySettings['proxy_login'] = $proxy->login; |
|
129 | - $proxySettings['proxy_password'] = $proxy->password; |
|
130 | - $soapClientArray = array_merge($soapClientArray, $proxySettings); |
|
125 | + $proxySettings = array(); |
|
126 | + $proxySettings['proxy_host'] = $proxy->host; |
|
127 | + $proxySettings['proxy_port'] = $proxy->port; // Use an integer, not a string |
|
128 | + $proxySettings['proxy_login'] = $proxy->login; |
|
129 | + $proxySettings['proxy_password'] = $proxy->password; |
|
130 | + $soapClientArray = array_merge($soapClientArray, $proxySettings); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | $this->sforce = $this->getSoapClient($wsdl, $soapClientArray); |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @return LogoutResult |
179 | 179 | */ |
180 | 180 | public function logout() { |
181 | - $this->setHeaders("logout"); |
|
181 | + $this->setHeaders("logout"); |
|
182 | 182 | $arg = new stdClass(); |
183 | 183 | return $this->sforce->logout(); |
184 | 184 | } |
@@ -189,9 +189,9 @@ discard block |
||
189 | 189 | * @return invalidateSessionsResult |
190 | 190 | */ |
191 | 191 | public function invalidateSessions() { |
192 | - $this->setHeaders("invalidateSessions"); |
|
192 | + $this->setHeaders("invalidateSessions"); |
|
193 | 193 | $arg = new stdClass(); |
194 | - $this->logout(); |
|
194 | + $this->logout(); |
|
195 | 195 | return $this->sforce->invalidateSessions(); |
196 | 196 | } |
197 | 197 |
@@ -28,177 +28,177 @@ |
||
28 | 28 | |
29 | 29 | class SforceCustomObject { |
30 | 30 | public function setDeploymentStatus($deploymentStatus) { |
31 | - $this->deploymentStatus = $deploymentStatus; |
|
31 | + $this->deploymentStatus = $deploymentStatus; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | public function setDescription($description) { |
35 | - $this->description = $description; |
|
35 | + $this->description = $description; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function setEnableActivities($enableActivities) { |
39 | - $this->enableActivities = $enableActivities; |
|
39 | + $this->enableActivities = $enableActivities; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function setEnableDivisions($enableDivisions) { |
43 | - $this->enableDivisions = $enableDivisions; |
|
43 | + $this->enableDivisions = $enableDivisions; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | public function setEnableHistory($enableHistory) { |
47 | - $this->enableHistory = $enableHistory; |
|
47 | + $this->enableHistory = $enableHistory; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function setEnableReports($enableReports) { |
51 | - $this->enableReports = $enableReports; |
|
51 | + $this->enableReports = $enableReports; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public function setFields($fields) { |
55 | - $this->fields = $fields; |
|
55 | + $this->fields = $fields; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | public function setFullName($fullName) { |
59 | - $this->fullName = $fullName; |
|
59 | + $this->fullName = $fullName; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | public function setGender($gender) { |
63 | - $this->gender = $gender; |
|
63 | + $this->gender = $gender; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | public function setHousehold($household) { |
67 | - $this->household = $household; |
|
67 | + $this->household = $household; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | public function setLabel($label) { |
71 | - $this->label = $label; |
|
71 | + $this->label = $label; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | public function setNameField($nameField) { |
75 | - $this->nameField = $nameField; |
|
75 | + $this->nameField = $nameField; |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | public function setPluralLabel($pluralLabel) { |
79 | - $this->pluralLabel = $pluralLabel; |
|
79 | + $this->pluralLabel = $pluralLabel; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | public function setSharingModel($sharingModel) { |
83 | - $this->sharingModel = $sharingModel; |
|
83 | + $this->sharingModel = $sharingModel; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | public function setStartsWith($startsWith) { |
87 | - $this->startsWith = $startsWith; |
|
87 | + $this->startsWith = $startsWith; |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | 91 | class SforceCustomField { |
92 | 92 | public function setCaseSensitive($caseSensitive) { |
93 | - $this->caseSensitive = $caseSensitive; |
|
93 | + $this->caseSensitive = $caseSensitive; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | public function setDefaultValue($defaultValue) { |
97 | - $this->defaultValue = $defaultValue; |
|
97 | + $this->defaultValue = $defaultValue; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | public function setDescription($description) { |
101 | - $this->description = $description; |
|
101 | + $this->description = $description; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | public function setDisplayFormat($displayFormat) { |
105 | - $this->displayFormat = $displayFormat; |
|
105 | + $this->displayFormat = $displayFormat; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | public function setExternalId($externalId) { |
109 | - $this->externalId = $externalId; |
|
109 | + $this->externalId = $externalId; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | public function setFormula($formula) { |
113 | - $this->formula = $formula; |
|
113 | + $this->formula = $formula; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | public function setFormulaTreatBlankAs($formulaTreatBlankAs) { |
117 | - $this->formulaTreatBlankAs = $formulaTreatBlankAs; |
|
117 | + $this->formulaTreatBlankAs = $formulaTreatBlankAs; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | public function setFullName($fullName) { |
121 | - $this->fullName = $fullName; |
|
121 | + $this->fullName = $fullName; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | public function setInlineHelpText($inlineHelpText) { |
125 | - $this->inlineHelpText = $inlineHelpText; |
|
125 | + $this->inlineHelpText = $inlineHelpText; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | public function setLabel($label) { |
129 | - $this->label = $label; |
|
129 | + $this->label = $label; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | public function setLength($length) { |
133 | - $this->length = $length; |
|
133 | + $this->length = $length; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | public function setMaskChar($maskChar) { |
137 | - $this->maskChar = $maskChar; |
|
137 | + $this->maskChar = $maskChar; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | public function setMaskType($maskType) { |
141 | - $this->maskType = $maskType; |
|
141 | + $this->maskType = $maskType; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | public function setPicklist($picklist) { |
145 | - $this->picklist = $picklist; |
|
145 | + $this->picklist = $picklist; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | public function setPopulateExistingRows($populateExistingRows) { |
149 | - $this->populateExistingRows = $populateExistingRows; |
|
149 | + $this->populateExistingRows = $populateExistingRows; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | public function setPrecision($precision) { |
153 | - $this->precision = $precision; |
|
153 | + $this->precision = $precision; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | public function setReferenceTo($referenceTo) { |
157 | - $this->referenceTo = $referenceTo; |
|
157 | + $this->referenceTo = $referenceTo; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | public function setRelationshipName($relationshipName) { |
161 | - $this->relationshipName = $relationshipName; |
|
161 | + $this->relationshipName = $relationshipName; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | public function setRequired($required) { |
165 | - $this->required = $required; |
|
165 | + $this->required = $required; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | public function setScale($scale) { |
169 | - $this->scale = $scale; |
|
169 | + $this->scale = $scale; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | public function setStartingNumber($startingNumber) { |
173 | - $this->startingNumber = $startingNumber; |
|
173 | + $this->startingNumber = $startingNumber; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | public function setSummarizeField($summarizeField) { |
177 | - $this->summarizeField = $summarizeField; |
|
177 | + $this->summarizeField = $summarizeField; |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | public function setSummaryFilterItems($summaryFilterItems) { |
181 | - $this->summaryFilterItems = $summaryFilterItems; |
|
181 | + $this->summaryFilterItems = $summaryFilterItems; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | public function setSummaryForeignKey($summaryForeignKey) { |
185 | - $this->summaryForeignKey = $summaryForeignKey; |
|
185 | + $this->summaryForeignKey = $summaryForeignKey; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | public function setSummaryOperation($summaryOperation) { |
189 | - $this->summaryOperation = $summaryOperation; |
|
189 | + $this->summaryOperation = $summaryOperation; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | public function setType($type) { |
193 | - $this->type = $type; |
|
193 | + $this->type = $type; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | public function setUnique($unique) { |
197 | - $this->unique = $unique; |
|
197 | + $this->unique = $unique; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | public function setVisibleLines($visibleLines) { |
201 | - $this->visibleLines = $visibleLines; |
|
201 | + $this->visibleLines = $visibleLines; |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | ?> |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | public $portalId; |
97 | 97 | |
98 | 98 | public function __construct($orgId = NULL, $portalId = NULL) { |
99 | - $this->organizationId = $orgId; |
|
100 | - $this->portalId = $portalId; |
|
99 | + $this->organizationId = $orgId; |
|
100 | + $this->portalId = $portalId; |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
@@ -141,42 +141,42 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | class AllowFieldTruncationHeader { |
144 | - public $allowFieldTruncation; |
|
144 | + public $allowFieldTruncation; |
|
145 | 145 | |
146 | - public function __construct($allowFieldTruncation) { |
|
147 | - $this->allowFieldTruncation = $allowFieldTruncation; |
|
148 | - } |
|
146 | + public function __construct($allowFieldTruncation) { |
|
147 | + $this->allowFieldTruncation = $allowFieldTruncation; |
|
148 | + } |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | class LocaleOptions { |
152 | - public $language; |
|
152 | + public $language; |
|
153 | 153 | |
154 | - /** |
|
155 | - * Class constructor. |
|
156 | - * |
|
157 | - * @param string $language |
|
158 | - * @return void |
|
159 | - */ |
|
160 | - public function __construct($language) { |
|
161 | - $this->language = $language; |
|
162 | - } |
|
154 | + /** |
|
155 | + * Class constructor. |
|
156 | + * |
|
157 | + * @param string $language |
|
158 | + * @return void |
|
159 | + */ |
|
160 | + public function __construct($language) { |
|
161 | + $this->language = $language; |
|
162 | + } |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | class PackageVersionHeader { |
166 | - /** |
|
167 | - * @var array $packageVersions |
|
168 | - */ |
|
169 | - public $packageVersions; |
|
166 | + /** |
|
167 | + * @var array $packageVersions |
|
168 | + */ |
|
169 | + public $packageVersions; |
|
170 | 170 | |
171 | - /** |
|
172 | - * Class constructor. |
|
173 | - * |
|
174 | - * @param array $packageVersions |
|
175 | - * @return void |
|
176 | - */ |
|
177 | - public function __construct($packageVersions) { |
|
178 | - $this->packageVersions = $packageVersions; |
|
179 | - } |
|
171 | + /** |
|
172 | + * Class constructor. |
|
173 | + * |
|
174 | + * @param array $packageVersions |
|
175 | + * @return void |
|
176 | + */ |
|
177 | + public function __construct($packageVersions) { |
|
178 | + $this->packageVersions = $packageVersions; |
|
179 | + } |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -184,23 +184,23 @@ discard block |
||
184 | 184 | * @see PackageVersionHeader |
185 | 185 | */ |
186 | 186 | class PackageVersion { |
187 | - public $majorNumber; |
|
188 | - public $minorNumber; |
|
189 | - public $namespace; |
|
187 | + public $majorNumber; |
|
188 | + public $minorNumber; |
|
189 | + public $namespace; |
|
190 | 190 | |
191 | - /** |
|
192 | - * Class constructor. |
|
193 | - * |
|
194 | - * @param int $majorNumber |
|
195 | - * @param int $minorNumber |
|
196 | - * @param string $namespace |
|
197 | - * @return void |
|
198 | - */ |
|
199 | - public function __construct($majorNumber, $minorNumber, $namespace) { |
|
200 | - $this->majorNumber = $majorNumber; |
|
201 | - $this->minorNumber = $minorNumber; |
|
202 | - $this->namespace = $namespace; |
|
203 | - } |
|
191 | + /** |
|
192 | + * Class constructor. |
|
193 | + * |
|
194 | + * @param int $majorNumber |
|
195 | + * @param int $minorNumber |
|
196 | + * @param string $namespace |
|
197 | + * @return void |
|
198 | + */ |
|
199 | + public function __construct($majorNumber, $minorNumber, $namespace) { |
|
200 | + $this->majorNumber = $majorNumber; |
|
201 | + $this->minorNumber = $minorNumber; |
|
202 | + $this->namespace = $namespace; |
|
203 | + } |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | ?> |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | class SforceEnterpriseClient extends SforceBaseClient { |
38 | 38 | const ENTERPRISE_NAMESPACE = 'urn:enterprise.soap.sforce.com'; |
39 | 39 | public function __construct() { |
40 | - $this->namespace = self::ENTERPRISE_NAMESPACE; |
|
40 | + $this->namespace = self::ENTERPRISE_NAMESPACE; |
|
41 | 41 | } |
42 | 42 | /** |
43 | 43 | * Adds one or more new individual objects to your organization's data. |
@@ -47,26 +47,26 @@ discard block |
||
47 | 47 | * @return SaveResult |
48 | 48 | */ |
49 | 49 | public function create($sObjects, $type) { |
50 | - $arg = []; |
|
51 | - foreach ($sObjects as $sObject) { |
|
52 | - // FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #1) |
|
50 | + $arg = []; |
|
51 | + foreach ($sObjects as $sObject) { |
|
52 | + // FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #1) |
|
53 | 53 | $xmlStr = ''; |
54 | - if(isset($sObject->fieldsToNull) && is_array($sObject->fieldsToNull)) { |
|
55 | - foreach($sObject->fieldsToNull as $fieldToNull) { |
|
56 | - $xmlStr .= '<fieldsToNull>' . $fieldToNull . '</fieldsToNull>'; |
|
57 | - } |
|
58 | - } |
|
59 | - // ------ |
|
54 | + if(isset($sObject->fieldsToNull) && is_array($sObject->fieldsToNull)) { |
|
55 | + foreach($sObject->fieldsToNull as $fieldToNull) { |
|
56 | + $xmlStr .= '<fieldsToNull>' . $fieldToNull . '</fieldsToNull>'; |
|
57 | + } |
|
58 | + } |
|
59 | + // ------ |
|
60 | 60 | |
61 | - $soapObject = new SoapVar($sObject, SOAP_ENC_OBJECT, $type, $this->namespace); |
|
62 | - // FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #2) |
|
63 | - if($xmlStr != '') { |
|
64 | - $soapObject->enc_value->fieldsToNull = new SoapVar(new SoapVar($xmlStr, XSD_ANYXML), SOAP_ENC_ARRAY); |
|
65 | - } |
|
66 | - // ------ |
|
67 | - $arg[] = $soapObject; |
|
68 | - } |
|
69 | - return parent::_create(new SoapParam($arg, "sObjects")); |
|
61 | + $soapObject = new SoapVar($sObject, SOAP_ENC_OBJECT, $type, $this->namespace); |
|
62 | + // FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #2) |
|
63 | + if($xmlStr != '') { |
|
64 | + $soapObject->enc_value->fieldsToNull = new SoapVar(new SoapVar($xmlStr, XSD_ANYXML), SOAP_ENC_ARRAY); |
|
65 | + } |
|
66 | + // ------ |
|
67 | + $arg[] = $soapObject; |
|
68 | + } |
|
69 | + return parent::_create(new SoapParam($arg, "sObjects")); |
|
70 | 70 | } |
71 | 71 | /** |
72 | 72 | * Updates one or more new individual objects to your organization's data. |
@@ -77,28 +77,28 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function update($sObjects, $type, $assignment_header = NULL, $mru_header = NULL) { |
79 | 79 | $arg = new stdClass; |
80 | - $arg->sObjects = []; |
|
81 | - foreach ($sObjects as $sObject) { |
|
82 | - // FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #1) |
|
80 | + $arg->sObjects = []; |
|
81 | + foreach ($sObjects as $sObject) { |
|
82 | + // FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #1) |
|
83 | 83 | $xmlStr = ''; |
84 | - if(isset($sObject->fieldsToNull) && is_array($sObject->fieldsToNull)) { |
|
85 | - foreach($sObject->fieldsToNull as $fieldToNull) { |
|
86 | - $xmlStr .= '<fieldsToNull>' . $fieldToNull . '</fieldsToNull>'; |
|
87 | - } |
|
88 | - } |
|
89 | - // ------ |
|
84 | + if(isset($sObject->fieldsToNull) && is_array($sObject->fieldsToNull)) { |
|
85 | + foreach($sObject->fieldsToNull as $fieldToNull) { |
|
86 | + $xmlStr .= '<fieldsToNull>' . $fieldToNull . '</fieldsToNull>'; |
|
87 | + } |
|
88 | + } |
|
89 | + // ------ |
|
90 | 90 | |
91 | - $soapObject = new SoapVar($sObject, SOAP_ENC_OBJECT, $type, $this->namespace); |
|
91 | + $soapObject = new SoapVar($sObject, SOAP_ENC_OBJECT, $type, $this->namespace); |
|
92 | 92 | |
93 | - // FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #2) |
|
94 | - if($xmlStr != '') { |
|
95 | - $soapObject->enc_value->fieldsToNull = new SoapVar(new SoapVar($xmlStr, XSD_ANYXML), SOAP_ENC_ARRAY); |
|
96 | - } |
|
97 | - // ------ |
|
98 | - $arg->sObjects[] = $soapObject; |
|
99 | - } |
|
93 | + // FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #2) |
|
94 | + if($xmlStr != '') { |
|
95 | + $soapObject->enc_value->fieldsToNull = new SoapVar(new SoapVar($xmlStr, XSD_ANYXML), SOAP_ENC_ARRAY); |
|
96 | + } |
|
97 | + // ------ |
|
98 | + $arg->sObjects[] = $soapObject; |
|
99 | + } |
|
100 | 100 | |
101 | - return parent::_update($arg); |
|
101 | + return parent::_update($arg); |
|
102 | 102 | } |
103 | 103 | /** |
104 | 104 | * Creates new objects and updates existing objects; uses a custom field to |
@@ -112,29 +112,29 @@ discard block |
||
112 | 112 | * @return UpsertResult |
113 | 113 | */ |
114 | 114 | public function upsert($ext_Id, $sObjects, $type = 'Contact') { |
115 | - $arg = new stdClass; |
|
116 | - $arg->sObjects = []; |
|
117 | - $arg->externalIDFieldName = new SoapVar($ext_Id, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema'); |
|
118 | - foreach ($sObjects as $sObject) { |
|
119 | - // FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #1) |
|
115 | + $arg = new stdClass; |
|
116 | + $arg->sObjects = []; |
|
117 | + $arg->externalIDFieldName = new SoapVar($ext_Id, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema'); |
|
118 | + foreach ($sObjects as $sObject) { |
|
119 | + // FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #1) |
|
120 | 120 | $xmlStr = ''; |
121 | - if(isset($sObject->fieldsToNull) && is_array($sObject->fieldsToNull)) { |
|
122 | - foreach($sObject->fieldsToNull as $fieldToNull) { |
|
123 | - $xmlStr .= '<fieldsToNull>' . $fieldToNull . '</fieldsToNull>'; |
|
124 | - } |
|
125 | - } |
|
126 | - // ------ |
|
121 | + if(isset($sObject->fieldsToNull) && is_array($sObject->fieldsToNull)) { |
|
122 | + foreach($sObject->fieldsToNull as $fieldToNull) { |
|
123 | + $xmlStr .= '<fieldsToNull>' . $fieldToNull . '</fieldsToNull>'; |
|
124 | + } |
|
125 | + } |
|
126 | + // ------ |
|
127 | 127 | |
128 | - $soapObject = new SoapVar($sObject, SOAP_ENC_OBJECT, $type, $this->namespace); |
|
128 | + $soapObject = new SoapVar($sObject, SOAP_ENC_OBJECT, $type, $this->namespace); |
|
129 | 129 | // FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #2) |
130 | 130 | if($xmlStr != '') { |
131 | 131 | $soapObject->enc_value->fieldsToNull = new SoapVar(new SoapVar($xmlStr, XSD_ANYXML), SOAP_ENC_ARRAY); |
132 | 132 | } |
133 | 133 | // ------ |
134 | 134 | $arg->sObjects[] = $soapObject; |
135 | - } |
|
135 | + } |
|
136 | 136 | |
137 | - return parent::_upsert($arg); |
|
137 | + return parent::_upsert($arg); |
|
138 | 138 | } |
139 | 139 | /** |
140 | 140 | * Merge records |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | * @return unknown |
145 | 145 | */ |
146 | 146 | public function merge($mergeRequest, $type) { |
147 | - $mergeRequest->masterRecord = new SoapVar($mergeRequest->masterRecord, SOAP_ENC_OBJECT, $type, $this->namespace); |
|
148 | - $arg = new stdClass; |
|
149 | - $arg->request = new SoapVar($mergeRequest, SOAP_ENC_OBJECT, 'MergeRequest', $this->namespace); |
|
150 | - return parent::_merge($arg); |
|
147 | + $mergeRequest->masterRecord = new SoapVar($mergeRequest->masterRecord, SOAP_ENC_OBJECT, $type, $this->namespace); |
|
148 | + $arg = new stdClass; |
|
149 | + $arg->request = new SoapVar($mergeRequest, SOAP_ENC_OBJECT, 'MergeRequest', $this->namespace); |
|
150 | + return parent::_merge($arg); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | ?> |
@@ -43,26 +43,26 @@ discard block |
||
43 | 43 | // xsi:type forces PHP SOAP to just leave the tags intact |
44 | 44 | class SforceSoapClient extends SoapClient { |
45 | 45 | function __doRequest($request, $location, $action, $version, $one_way=0) { |
46 | - $response = parent::__doRequest($request, $location, $action, $version, $one_way); |
|
46 | + $response = parent::__doRequest($request, $location, $action, $version, $one_way); |
|
47 | 47 | |
48 | - // Quick check to only parse the XML here if we think we need to |
|
49 | - if (strpos($response, '<sf:OldValue') === false && strpos($response, '<sf:NewValue') === false) { |
|
50 | - return $response; |
|
51 | - } |
|
48 | + // Quick check to only parse the XML here if we think we need to |
|
49 | + if (strpos($response, '<sf:OldValue') === false && strpos($response, '<sf:NewValue') === false) { |
|
50 | + return $response; |
|
51 | + } |
|
52 | 52 | |
53 | - $dom = new DOMDocument(); |
|
54 | - $dom->loadXML($response); |
|
53 | + $dom = new DOMDocument(); |
|
54 | + $dom->loadXML($response); |
|
55 | 55 | |
56 | - $nodeList = $dom->getElementsByTagName('NewValue'); |
|
57 | - foreach ($nodeList as $node) { |
|
58 | - $node->removeAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'type'); |
|
59 | - } |
|
60 | - $nodeList = $dom->getElementsByTagName('OldValue'); |
|
61 | - foreach ($nodeList as $node) { |
|
62 | - $node->removeAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'type'); |
|
63 | - } |
|
56 | + $nodeList = $dom->getElementsByTagName('NewValue'); |
|
57 | + foreach ($nodeList as $node) { |
|
58 | + $node->removeAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'type'); |
|
59 | + } |
|
60 | + $nodeList = $dom->getElementsByTagName('OldValue'); |
|
61 | + foreach ($nodeList as $node) { |
|
62 | + $node->removeAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'type'); |
|
63 | + } |
|
64 | 64 | |
65 | - return $dom->saveXML(); |
|
65 | + return $dom->saveXML(); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | const PARTNER_NAMESPACE = 'urn:partner.soap.sforce.com'; |
76 | 76 | |
77 | 77 | public function __construct() { |
78 | - $this->namespace = self::PARTNER_NAMESPACE; |
|
78 | + $this->namespace = self::PARTNER_NAMESPACE; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | protected function getSoapClient($wsdl, $options) { |
82 | - // Workaround an issue in parsing OldValue and NewValue in histories |
|
82 | + // Workaround an issue in parsing OldValue and NewValue in histories |
|
83 | 83 | return new SforceSoapClient($wsdl, $options); |
84 | 84 | } |
85 | 85 | |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | * @return SaveResult |
90 | 90 | */ |
91 | 91 | public function create($sObjects) { |
92 | - $arg = new stdClass; |
|
93 | - foreach ($sObjects as $sObject) { |
|
94 | - if (isset ($sObject->fields)) { |
|
95 | - $sObject->any = $this->_convertToAny($sObject->fields); |
|
96 | - } |
|
97 | - } |
|
98 | - $arg->sObjects = $sObjects; |
|
99 | - return parent::_create($arg); |
|
92 | + $arg = new stdClass; |
|
93 | + foreach ($sObjects as $sObject) { |
|
94 | + if (isset ($sObject->fields)) { |
|
95 | + $sObject->any = $this->_convertToAny($sObject->fields); |
|
96 | + } |
|
97 | + } |
|
98 | + $arg->sObjects = $sObjects; |
|
99 | + return parent::_create($arg); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -107,14 +107,14 @@ discard block |
||
107 | 107 | * @return mixed |
108 | 108 | */ |
109 | 109 | public function merge($mergeRequest) { |
110 | - if (isset($mergeRequest->masterRecord)) { |
|
111 | - if (isset($mergeRequest->masterRecord->fields)) { |
|
112 | - $mergeRequest->masterRecord->any = $this->_convertToAny($mergeRequest->masterRecord->fields); |
|
113 | - } |
|
114 | - //return parent::merge($mergeRequest, $type); |
|
115 | - $arg->request = $mergeRequest; |
|
116 | - return $this->_merge($arg); |
|
117 | - } |
|
110 | + if (isset($mergeRequest->masterRecord)) { |
|
111 | + if (isset($mergeRequest->masterRecord->fields)) { |
|
112 | + $mergeRequest->masterRecord->any = $this->_convertToAny($mergeRequest->masterRecord->fields); |
|
113 | + } |
|
114 | + //return parent::merge($mergeRequest, $type); |
|
115 | + $arg->request = $mergeRequest; |
|
116 | + return $this->_merge($arg); |
|
117 | + } |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -122,18 +122,18 @@ discard block |
||
122 | 122 | * @param array $request |
123 | 123 | */ |
124 | 124 | public function sendSingleEmail($request) { |
125 | - if (is_array($request)) { |
|
126 | - $messages = array(); |
|
127 | - foreach ($request as $r) { |
|
128 | - $email = new SoapVar($r, SOAP_ENC_OBJECT, 'SingleEmailMessage', $this->namespace); |
|
129 | - array_push($messages, $email); |
|
130 | - } |
|
131 | - $arg->messages = $messages; |
|
132 | - return parent::_sendEmail($arg); |
|
133 | - } else { |
|
134 | - $backtrace = debug_backtrace(); |
|
135 | - die('Please pass in array to this function: '.$backtrace[0]['function']); |
|
136 | - } |
|
125 | + if (is_array($request)) { |
|
126 | + $messages = array(); |
|
127 | + foreach ($request as $r) { |
|
128 | + $email = new SoapVar($r, SOAP_ENC_OBJECT, 'SingleEmailMessage', $this->namespace); |
|
129 | + array_push($messages, $email); |
|
130 | + } |
|
131 | + $arg->messages = $messages; |
|
132 | + return parent::_sendEmail($arg); |
|
133 | + } else { |
|
134 | + $backtrace = debug_backtrace(); |
|
135 | + die('Please pass in array to this function: '.$backtrace[0]['function']); |
|
136 | + } |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -141,18 +141,18 @@ discard block |
||
141 | 141 | * @param array $request |
142 | 142 | */ |
143 | 143 | public function sendMassEmail($request) { |
144 | - if (is_array($request)) { |
|
145 | - $messages = array(); |
|
146 | - foreach ($request as $r) { |
|
147 | - $email = new SoapVar($r, SOAP_ENC_OBJECT, 'MassEmailMessage', $this->namespace); |
|
148 | - array_push($messages, $email); |
|
149 | - } |
|
150 | - $arg->messages = $messages; |
|
151 | - return parent::_sendEmail($arg); |
|
152 | - } else { |
|
153 | - $backtrace = debug_backtrace(); |
|
154 | - die('Please pass in array to this function: '.$backtrace[0]['function']); |
|
155 | - } |
|
144 | + if (is_array($request)) { |
|
145 | + $messages = array(); |
|
146 | + foreach ($request as $r) { |
|
147 | + $email = new SoapVar($r, SOAP_ENC_OBJECT, 'MassEmailMessage', $this->namespace); |
|
148 | + array_push($messages, $email); |
|
149 | + } |
|
150 | + $arg->messages = $messages; |
|
151 | + return parent::_sendEmail($arg); |
|
152 | + } else { |
|
153 | + $backtrace = debug_backtrace(); |
|
154 | + die('Please pass in array to this function: '.$backtrace[0]['function']); |
|
155 | + } |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -161,14 +161,14 @@ discard block |
||
161 | 161 | * @return UpdateResult |
162 | 162 | */ |
163 | 163 | public function update($sObjects) { |
164 | - $arg = new stdClass; |
|
165 | - foreach ($sObjects as $sObject) { |
|
166 | - if (isset($sObject->fields)) { |
|
167 | - $sObject->any = $this->_convertToAny($sObject->fields); |
|
168 | - } |
|
169 | - } |
|
170 | - $arg->sObjects = $sObjects; |
|
171 | - return parent::_update($arg); |
|
164 | + $arg = new stdClass; |
|
165 | + foreach ($sObjects as $sObject) { |
|
166 | + if (isset($sObject->fields)) { |
|
167 | + $sObject->any = $this->_convertToAny($sObject->fields); |
|
168 | + } |
|
169 | + } |
|
170 | + $arg->sObjects = $sObjects; |
|
171 | + return parent::_update($arg); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -182,16 +182,16 @@ discard block |
||
182 | 182 | * @return UpsertResult |
183 | 183 | */ |
184 | 184 | public function upsert($ext_Id, $sObjects) { |
185 | - // $this->_setSessionHeader(); |
|
186 | - $arg = new stdClass; |
|
187 | - $arg->externalIDFieldName = new SoapVar($ext_Id, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema'); |
|
188 | - foreach ($sObjects as $sObject) { |
|
189 | - if (isset ($sObject->fields)) { |
|
190 | - $sObject->any = $this->_convertToAny($sObject->fields); |
|
191 | - } |
|
192 | - } |
|
193 | - $arg->sObjects = $sObjects; |
|
194 | - return parent::_upsert($arg); |
|
185 | + // $this->_setSessionHeader(); |
|
186 | + $arg = new stdClass; |
|
187 | + $arg->externalIDFieldName = new SoapVar($ext_Id, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema'); |
|
188 | + foreach ($sObjects as $sObject) { |
|
189 | + if (isset ($sObject->fields)) { |
|
190 | + $sObject->any = $this->_convertToAny($sObject->fields); |
|
191 | + } |
|
192 | + } |
|
193 | + $arg->sObjects = $sObjects; |
|
194 | + return parent::_upsert($arg); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | }; |
219 | 219 | }else { |
220 | 220 | $sobject = new SObject($response); |
221 | - array_push($arr, $sobject); |
|
221 | + array_push($arr, $sobject); |
|
222 | 222 | } |
223 | 223 | return $arr; |
224 | 224 | } |