$schedule_name
$schedule_name : string
Pull data from Salesforce into WordPress
__construct(object $wpdb, string $version, array $login_credentials, string $slug, object $wordpress, object $salesforce, object $mappings, object $logging, array $schedulable_classes, object $queue = '', string $option_prefix = '')
Constructor which sets up pull schedule
| object | $wpdb | |
| string | $version | |
| array | $login_credentials | |
| string | $slug | |
| object | $wordpress | |
| object | $salesforce | |
| object | $mappings | |
| object | $logging | |
| array | $schedulable_classes | |
| object | $queue | |
| string | $option_prefix |
add_actions()
Create the action hooks based on what object maps exist from the admin settings route is http://example.com/wp-json/salesforce-rest-api/pull/ plus params we decide to accept
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/jstegall/Sites/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1293 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/jstegall/Sites/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1293salesforce_pull_webhook(object $request) : array
REST API callback for salesforce pull. Returns status of 200 for successful attempt or 403 for a failed pull attempt (SF not authorized, threshhold reached, etc.
| object | $request | This is a merged object of all the arguments from the API request |
code: 201 data: success : true
salesforce_pull()
Callback for the standard pull process used by webhooks and cron.
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/jstegall/Sites/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1293 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/jstegall/Sites/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1293manual_pull(string $object_type, string $salesforce_id) : array
Method for ajax hooks to call for pulling manually
| string | $object_type | |
| string | $salesforce_id |
$result
salesforce_pull_process_records(string $object_type, array|string $object, array|integer $mapping, integer $sf_sync_trigger) : true
Sync WordPress objects and Salesforce objects from the queue using the REST API.
| string | $object_type | Type of Salesforce object. |
| array|string | $object | The Salesforce data or its Id value. |
| array|integer | $mapping | Salesforce/WP mapping data or its id. |
| integer | $sf_sync_trigger | Trigger for this sync. |
or exit the method
batch_soql_queries(boolean $batch_soql_queries) : boolean
Whether to use the batchSize parameter on SOQL queries
| boolean | $batch_soql_queries |
$batch_soql_queries
check_throttle() : boolean
Determines if the Salesforce pull should be allowed, or throttled.
Prevents too many pull processes from running at once.
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/jstegall/Sites/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1293 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/jstegall/Sites/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1293Returns false if the time elapsed between recent pulls is too short.
get_updated_records()
Pull updated records from Salesforce and place them in the queue.
Executes a SOQL query based on defined mappings, loops through the results, and places each updated SF object into the queue for later processing.
We copy the convention from the Drupal module here, and run a separate SOQL query for each type of object in SF
If we return something here, it's because there is an error.
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/jstegall/Sites/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1293 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/jstegall/Sites/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1293get_next_record_batch(\gmdate $last_sync, array $salesforce_mapping, array $map_sync_triggers, string $type, string $version_path, array $query_options, array $response)
Pull the next batch of records from the Salesforce API, if applicable
Executes a nextRecordsUrl SOQL query based on the previous result, and places each updated SF object into the queue for later processing.
| \gmdate | $last_sync | |
| array | $salesforce_mapping | |
| array | $map_sync_triggers | |
| string | $type | |
| string | $version_path | |
| array | $query_options | |
| array | $response |
check_offset_query(string $type, array $salesforce_mapping, array $query_options) : object|boolean
Get the next offset query. If check is true, only see if that query would have results. Otherwise, return the SOQL object.
When batchSize is not in use, run a check with an offset.
| string | $type | the Salesforce object type |
| array | $salesforce_mapping | the map between object types |
| array | $query_options | the options for the SOQL query |
$soql|$does_next_offset_have_results
get_pull_query(string $type, array $salesforce_mapping = array()) : \Object_Sync_Sf_Salesforce_Select_Query
Given a SObject type name, build an SOQL query to include all fields for all SalesforceMappings mapped to that SObject.
| string | $type | e.g. "Contact", "Account", etc. |
| array | $salesforce_mapping | the fieldmap that maps the two object types |
or null if no mappings or no mapped fields were found.
get_pull_offset(string $type, object $soql, boolean $reset = false)
Determine the offset for the SOQL query to run
| string | $type | e.g. "Contact", "Account", etc. |
| object | $soql | the SOQL object |
| boolean | $reset | whether to reset the offset |
get_pull_date_value(string $type, $soql) : \timestamp
Given a SObject type name, determine the datetime value the SOQL object should use to filter results. Often this will be LastModifiedDate.
| string | $type | e.g. "Contact", "Account", etc. |
| $soql |
$pull_trigger_field_value
get_deleted_records()
Get deleted records from salesforce.
Note that deletions can only be queried via REST with an API version >= 29.0.
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/jstegall/Sites/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1293 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/jstegall/Sites/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1293clear_current_type_query(string $type)
Clear the currently stored query for the specified content type
| string | $type | e.g. "Contact", "Account", etc. |
increment_current_type_datetime(string $type, \timestamp $next_query_modified_date = '')
Increment the currently running query's datetime
| string | $type | e.g. "Contact", "Account", etc. |
| \timestamp | $next_query_modified_date | the last record's modified datetime, or the current time if there isn't one |
create_object_map(array $salesforce_object, string $wordpress_id, array $field_mapping) : integer
Create an object map between a Salesforce object and a WordPress object
| array | $salesforce_object | Array of the salesforce object's data |
| string | $wordpress_id | Unique identifier for the WordPress object |
| array | $field_mapping | The row that maps the object types together, including which fields match which other fields |
$wpdb->insert_id This is the database row for the map object
is_pull_allowed(string $object_type, array $object, string $sf_sync_trigger, array $mapping, array $map_sync_triggers) : boolean
Find out if pull is allowed for this record
| string | $object_type | Salesforce object type |
| array | $object | Array of the salesforce object's data |
| string | $sf_sync_trigger | The current operation's trigger |
| array | $mapping | the fieldmap that maps the two object types |
| array | $map_sync_triggers |
$pull_allowed Whether all this stuff allows the $result to be pulled into WordPress