Properties

$schedule_name

$schedule_name : string

Type

string

$wpdb

$wpdb : 

Type

$version

$version : 

Type

$login_credentials

$login_credentials : 

Type

$slug

$slug : 

Type

$salesforce

$salesforce : 

Type

$mappings

$mappings : 

Type

$logging

$logging : 

Type

$schedulable_classes

$schedulable_classes : 

Type

$queue

$queue : 

Type

$option_prefix

$option_prefix : 

Type

Methods

__construct()

__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

Parameters

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

Throws

\Exception

add_actions()

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 1293

salesforce_pull_webhook()

salesforce_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.

Parameters

object $request

This is a merged object of all the arguments from the API request

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 1293

Returns

array —

code: 201 data: success : true

salesforce_pull()

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 1293

manual_pull()

manual_pull(string  $object_type, string  $salesforce_id) : array

Method for ajax hooks to call for pulling manually

Parameters

string $object_type
string $salesforce_id
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 1293

Returns

array —

$result

salesforce_pull_process_records()

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.

Parameters

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.

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 1293

Returns

true —

or exit the method

batch_soql_queries()

batch_soql_queries(boolean  $batch_soql_queries) : boolean

Whether to use the batchSize parameter on SOQL queries

Parameters

boolean $batch_soql_queries
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 1293

Returns

boolean —

$batch_soql_queries

check_throttle()

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 1293

Returns

boolean —

Returns false if the time elapsed between recent pulls is too short.

get_updated_records()

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 1293

get_next_record_batch()

get_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.

Parameters

\gmdate $last_sync
array $salesforce_mapping
array $map_sync_triggers
string $type
string $version_path
array $query_options
array $response
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 1293

check_offset_query()

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.

Parameters

string $type

the Salesforce object type

array $salesforce_mapping

the map between object types

array $query_options

the options for the SOQL query

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 1293

Returns

object|boolean —

$soql|$does_next_offset_have_results

get_pull_query()

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.

Parameters

string $type

e.g. "Contact", "Account", etc.

array $salesforce_mapping

the fieldmap that maps the two object types

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 1293

Returns

\Object_Sync_Sf_Salesforce_Select_Query

or null if no mappings or no mapped fields were found.

get_pull_offset()

get_pull_offset(string  $type, object  $soql, boolean  $reset = false) 

Determine the offset for the SOQL query to run

Parameters

string $type

e.g. "Contact", "Account", etc.

object $soql

the SOQL object

boolean $reset

whether to reset the offset

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 1293

get_pull_date_value()

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.

Parameters

string $type

e.g. "Contact", "Account", etc.

$soql
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 1293

Returns

\timestamp —

$pull_trigger_field_value

get_deleted_records()

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 1293

clear_current_type_query()

clear_current_type_query(string  $type) 

Clear the currently stored query for the specified content type

Parameters

string $type

e.g. "Contact", "Account", etc.

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 1293

increment_current_type_datetime()

increment_current_type_datetime(string  $type, \timestamp  $next_query_modified_date = '') 

Increment the currently running query's datetime

Parameters

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

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 1293

create_object_map()

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

Parameters

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

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 1293

Returns

integer —

$wpdb->insert_id This is the database row for the map object

is_pull_allowed()

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

Parameters

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
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 1293

Returns

boolean —

$pull_allowed Whether all this stuff allows the $result to be pulled into WordPress