Menu

## Object_Sync_Sf_Salesforce_Pull
in package

class-object-sync-sf-salesforce-pull.php : 14

Object_Sync_Sf_Salesforce_Pull class.

### Table of Contents

$debug : bool
  Whether the plugin is in debug mode
$file : string
  The main plugin file
$logging : object
  Object_Sync_Sf_Logging class
$login_credentials : array<string|int, mixed>
  Login credentials for the Salesforce API; comes from wp-config or from the plugin settings
$mappings : object
  Object_Sync_Sf_Mapping class
$mergeable_record_types : array<string|int, mixed>
  Types of Salesforce records that can be merged
$option_prefix : string
  The plugin's prefix when saving options to the database
$pull_options : object
  Object_Sync_Sf_Pull_Options class
$queue : object
  Object_Sync_Sf_Queue class
$salesforce : array<string|int, mixed>
  Object_Sync_Sf_Salesforce class This contains Salesforce API methods
$schedulable_classes : array<string|int, mixed>
  Array of what classes in the plugin can be scheduled to occur with `wp_cron` events
$schedule_name : string
  The name of the ActionScheduler queue
$slug : string
  The plugin's slug so we can include it when necessary
$sync_transients : object
  Object_Sync_Sf_Sync_Transients class
$version : string
  Current version of the plugin
$wordpress : object
  Object_Sync_Sf_WordPress class
$wpdb : object
  Global object of `$wpdb`, the WordPress database
$batch_soql_queries : bool
  Whether to batch SOQL queries
$max_soql_size : int
  Maximum size of a SOQL batch
$min_soql_batch_size : int
  Minimum size of a SOQL batch
__construct() : mixed
  Constructor for pull class
add_actions() : mixed
  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.
clear_current_type_query() : mixed
  Clear the currently stored query for the specified content type
deprecated_actions() : mixed
  Deprecated actions
deprecated_pull_option_names() : mixed
  Modify legacy named individual option records for sync operations
manual_pull() : array<string|int, mixed>
  Method for ajax hooks to call for pulling manually
salesforce_pull() : mixed
  Callback for the standard pull process used by webhooks and cron.
salesforce_pull_process_records() : bool
  Sync WordPress objects and Salesforce objects from the queue using the REST API.
salesforce_pull_webhook() : array<string|int, mixed>
  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.
batch_soql_queries() : bool
  Whether to use the batchSize parameter on SOQL queries
check_for_upsert() : string
  Determine whether the current operation is an upsert or a create.
check_offset_query() : object|bool
  Get the next offset query. If check is true, only see if that query would have results. Otherwise, return the SOQL object.
check_throttle() : bool
  Determines if the Salesforce pull should be allowed, or throttled.
create_called_from_salesforce() : array<string|int, mixed>
  Create records in WordPress from a Salesforce pull
create_object_map() : int
  Create an object map between a Salesforce object and a WordPress object
delete_called_from_salesforce() : array<string|int, mixed>
  Delete records in WordPress from a Salesforce pull
get_deleted_records() : mixed
  Get deleted records from salesforce.
get_merged_records() : mixed
  Get merged records from Salesforce.
get_next_record_batch() : mixed
  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.
get_pull_date_value() : timestamp
  Given a SObject type name, determine the datetime value the SOQL object should use to filter results. Often this will be LastModifiedDate.
get_pull_offset() : mixed
  Determine the offset for the SOQL query to run
get_pull_query() : Object_Sync_Sf_Salesforce_Select_Query
  Given a SObject type name, build an SOQL query to include all fields for all fieldmaps mapped to that SObject.
get_synced_object() : array<string|int, mixed>
  Generate the synced_object array
get_updated_records() : mixed
  Pull updated records from Salesforce and place them in the queue.
increment_current_type_datetime() : mixed
  Increment the currently running query's datetime
is_pull_allowed() : bool
  Find out if pull is allowed for this record
parse_error_message() : string
  Format the error message
respond_to_salesforce_merge() : mixed
  Respond to Salesforce merge events This means we update the mapping object to contain the new Salesforce Id, and pull its data
update_called_from_salesforce() : array<string|int, mixed>
  Update records in WordPress from a Salesforce pull

### Properties

#### $debug

class-object-sync-sf-salesforce-pull.php : 155

Whether the plugin is in debug mode

`public bool $debug`

#### $file

class-object-sync-sf-salesforce-pull.php : 28

The main plugin file

`public string $file`

#### $logging

class-object-sync-sf-salesforce-pull.php : 77

Object_Sync_Sf_Logging class

`public object $logging`

#### $login_credentials

class-object-sync-sf-salesforce-pull.php : 56

Login credentials for the Salesforce API; comes from wp-config or from the plugin settings

`public array<string|int, mixed> $login_credentials`

#### $mappings

class-object-sync-sf-salesforce-pull.php : 84

Object_Sync_Sf_Mapping class

`public object $mappings`

#### $mergeable_record_types

class-object-sync-sf-salesforce-pull.php : 148

Types of Salesforce records that can be merged

`public array<string|int, mixed> $mergeable_record_types`

#### $option_prefix

class-object-sync-sf-salesforce-pull.php : 49

The plugin's prefix when saving options to the database

`public string $option_prefix`

#### $pull_options

class-object-sync-sf-salesforce-pull.php : 106

Object_Sync_Sf_Pull_Options class

`public object $pull_options`

#### $queue

class-object-sync-sf-salesforce-pull.php : 70

Object_Sync_Sf_Queue class

`public object $queue`

#### $salesforce

class-object-sync-sf-salesforce-pull.php : 99

Object_Sync_Sf_Salesforce class This contains Salesforce API methods

`public array<string|int, mixed> $salesforce`

#### $schedulable_classes

class-object-sync-sf-salesforce-pull.php : 63

Array of what classes in the plugin can be scheduled to occur with `wp_cron` events

`public array<string|int, mixed> $schedulable_classes`

#### $schedule_name

class-object-sync-sf-salesforce-pull.php : 120

The name of the ActionScheduler queue

`public string $schedule_name`

#### $slug

class-object-sync-sf-salesforce-pull.php : 42

The plugin's slug so we can include it when necessary

`public string $slug`

#### $sync_transients

class-object-sync-sf-salesforce-pull.php : 113

Object_Sync_Sf_Sync_Transients class

`public object $sync_transients`

#### $version

class-object-sync-sf-salesforce-pull.php : 21

Current version of the plugin

`public string $version`

#### $wordpress

class-object-sync-sf-salesforce-pull.php : 91

Object_Sync_Sf_WordPress class

`public object $wordpress`

#### $wpdb

class-object-sync-sf-salesforce-pull.php : 35

Global object of `$wpdb`, the WordPress database

`public object $wpdb`

#### $batch_soql_queries

class-object-sync-sf-salesforce-pull.php : 127

Whether to batch SOQL queries

`private bool $batch_soql_queries`

#### $max_soql_size

class-object-sync-sf-salesforce-pull.php : 141

Maximum size of a SOQL batch

`private int $max_soql_size`

#### $min_soql_batch_size

class-object-sync-sf-salesforce-pull.php : 134

Minimum size of a SOQL batch

`private int $min_soql_batch_size`

### Methods

#### __construct()

class-object-sync-sf-salesforce-pull.php : 160

Constructor for pull class

`public __construct() : mixed`

##### Return values

mixed —

#### add_actions()

class-object-sync-sf-salesforce-pull.php : 221

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.

`public add_actions() : mixed`

##### Return values

mixed —

#### clear_current_type_query()

class-object-sync-sf-salesforce-pull.php : 2198

Clear the currently stored query for the specified content type

`public clear_current_type_query(string $type[, int $fieldmap_id = '' ]) : mixed`

##### Parameters

$type : string

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

$fieldmap_id : int = ''

  is the fieldmap ID that goes with this query.

##### Return values

mixed —

#### deprecated_actions()

class-object-sync-sf-salesforce-pull.php : 234

Deprecated actions

`public deprecated_actions() : mixed`

##### Return values

mixed —

#### deprecated_pull_option_names()

class-object-sync-sf-salesforce-pull.php : 247

Modify legacy named individual option records for sync operations

`public deprecated_pull_option_names(string $key, array<string|int, mixed> $params) : mixed`

##### Parameters

$key : string

  the plugin's suggested key name.

$params : array<string|int, mixed>

  the array of parameters to make the key.

##### Tags

deprecated

  this was added in 2.1.0 to upgrade old option keys, but will be removed in a future version.

##### Return values

mixed —

$value the value of the item. False if it's empty.

#### manual_pull()

class-object-sync-sf-salesforce-pull.php : 1193

Method for ajax hooks to call for pulling manually

`public manual_pull(string $object_type[, string $salesforce_id = '' ]) : array<string|int, mixed>`

##### Parameters

$object_type : string

  the Salesforce object type.

$salesforce_id : string = ''

  the Salesforce record ID.

##### Return values

array<string|int, mixed> —

$result

#### salesforce_pull()

class-object-sync-sf-salesforce-pull.php : 302

Callback for the standard pull process used by webhooks and cron.

`public salesforce_pull() : mixed`

##### Return values

mixed —

#### salesforce_pull_process_records()

class-object-sync-sf-salesforce-pull.php : 1229

Sync WordPress objects and Salesforce objects from the queue using the REST API.

`public salesforce_pull_process_records(string $object_type, array<string|int, mixed>|string $object, int $sf_sync_trigger) : bool`

##### Parameters

$object_type : string

  Type of Salesforce object.

$object : array<string|int, mixed>|string

  The Salesforce data or its Id value.

$sf_sync_trigger : int

  Trigger for this sync.

##### Tags

throws
  Object_Sync_Sf_Exception

  Exception $e.

##### Return values

bool —

true or exit the method

#### salesforce_pull_webhook()

class-object-sync-sf-salesforce-pull.php : 270

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.

`public salesforce_pull_webhook(WP_REST_Request $request) : array<string|int, mixed>`

##### Parameters

$request : WP_REST_Request

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

##### Return values

array<string|int, mixed> —

code: 201 data: success : true

#### batch_soql_queries()

class-object-sync-sf-salesforce-pull.php : 207

Whether to use the batchSize parameter on SOQL queries

`private batch_soql_queries(bool $batch_soql_queries) : bool`

##### Parameters

$batch_soql_queries : bool

  whether to batch the queries.

##### Return values

bool —

$batch_soql_queries

#### check_for_upsert()

class-object-sync-sf-salesforce-pull.php : 1894

Determine whether the current operation is an upsert or a create.

`private check_for_upsert(array<string|int, mixed> $prematch, int|null $wordpress_id) : string`

##### Parameters

$prematch : array<string|int, mixed>

  Array of criteria to determine what to do on upsert operations.

$wordpress_id : int|null

  The value of the WordPress ID.

##### Return values

string —

$op Whether it's an upsert or create.

#### check_offset_query()

class-object-sync-sf-salesforce-pull.php : 695

Get the next offset query. If check is true, only see if that query would have results. Otherwise, return the SOQL object.

`private check_offset_query(string $type, array<string|int, mixed> $salesforce_mapping, array<string|int, mixed> $query_options) : object|bool`

When batchSize is not in use, run a check with an offset.

##### Parameters

$type : string

  the Salesforce object type.

$salesforce_mapping : array<string|int, mixed>

  the map between object types.

$query_options : array<string|int, mixed>

  the options for the SOQL query.

##### Return values

object|bool —

$soql|$does_next_offset_have_results

#### check_throttle()

class-object-sync-sf-salesforce-pull.php : 327

Determines if the Salesforce pull should be allowed, or throttled.

`private check_throttle() : bool`

Prevents too many pull processes from running at once.

##### Return values

bool —

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

#### create_called_from_salesforce()

class-object-sync-sf-salesforce-pull.php : 1586

Create records in WordPress from a Salesforce pull

`private create_called_from_salesforce(string $sf_sync_trigger, array<string|int, mixed> $synced_object, array<string|int, mixed> $params, array<string|int, mixed> $prematch, string $wordpress_id_field_name, int $seconds) : array<string|int, mixed>`

##### Parameters

$sf_sync_trigger : string

  The current operation's trigger.

$synced_object : array<string|int, mixed>

  Combined data for fieldmap, mapping object, and Salesforce object data.

$params : array<string|int, mixed>

  Array of mapped key value pairs between WordPress and Salesforce fields.

$prematch : array<string|int, mixed>

  Array of criteria to determine what to do on upsert operations.

$wordpress_id_field_name : string

  The name of the ID field for this particular WordPress object type.

$seconds : int

  Timeout for the transient value to determine the direction for a sync.

##### Tags

throws
  Object_Sync_Sf_Exception

  Exception $e.

##### Return values

array<string|int, mixed> —

$results Currently this contains an array of log entries for each attempt.

#### create_object_map()

class-object-sync-sf-salesforce-pull.php : 2232

Create an object map between a Salesforce object and a WordPress object

`private create_object_map(array<string|int, mixed> $salesforce_object, string $wordpress_id, array<string|int, mixed> $field_mapping) : int`

##### Parameters

$salesforce_object : array<string|int, mixed>

  Array of the salesforce object's data.

$wordpress_id : string

  Unique identifier for the WordPress object.

$field_mapping : array<string|int, mixed>

  The row that maps the object types together, including which fields match which other fields.

##### Return values

int —

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

#### delete_called_from_salesforce()

class-object-sync-sf-salesforce-pull.php : 2036

Delete records in WordPress from a Salesforce pull

`private delete_called_from_salesforce(string $sf_sync_trigger, array<string|int, mixed> $synced_object, string $wordpress_id_field_name, int $seconds, array<string|int, mixed> $mapping_objects) : array<string|int, mixed>`

##### Parameters

$sf_sync_trigger : string

  The current operation's trigger.

$synced_object : array<string|int, mixed>

  Combined data for fieldmap, mapping object, and Salesforce object data.

$wordpress_id_field_name : string

  The name of the ID field for this particular WordPress object type.

$seconds : int

  Timeout for the transient value to determine the direction for a sync.

$mapping_objects : array<string|int, mixed>

  The data for the mapping objects between the individual Salesforce and WordPress items. We only pass this because of the need to count before deleting records.

##### Tags

throws
  Object_Sync_Sf_Exception

  Exception $e.

##### Return values

array<string|int, mixed> —

$results Currently this contains an array of log entries for each attempt.

#### get_deleted_records()

class-object-sync-sf-salesforce-pull.php : 1051

Get deleted records from salesforce.

`private get_deleted_records() : mixed`

Note that deletions can only be queried via REST with an API version >= 29.0.

##### Return values

mixed —

#### get_merged_records()

class-object-sync-sf-salesforce-pull.php : 920

Get merged records from Salesforce.

`private get_merged_records() : mixed`

Note that merges can currently only work if the Soap API is enabled.

##### Return values

mixed —

#### get_next_record_batch()

class-object-sync-sf-salesforce-pull.php : 638

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.

`private get_next_record_batch(datetime $last_sync, array<string|int, mixed> $salesforce_mapping, array<string|int, mixed> $map_sync_triggers, string $type, string $version_path, array<string|int, mixed> $query_options, array<string|int, mixed> $response) : mixed`

##### Parameters

$last_sync : datetime

  when it was last synced.

$salesforce_mapping : array<string|int, mixed>

  the fieldmap.

$map_sync_triggers : array<string|int, mixed>

  the sync trigger bit values.

$type : string

  the Salesforce object type.

$version_path : string

  the API path for the Salesforce version.

$query_options : array<string|int, mixed>

  the SOQL query options.

$response : array<string|int, mixed>

  the previous response.

##### Return values

mixed —

#### get_pull_date_value()

class-object-sync-sf-salesforce-pull.php : 883

Given a SObject type name, determine the datetime value the SOQL object should use to filter results. Often this will be LastModifiedDate.

`private get_pull_date_value(string $type, object $soql[, int $fieldmap_id = '' ]) : timestamp`

##### Parameters

$type : string

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

$soql : object

  the SOQL object.

$fieldmap_id : int = ''

  is the fieldmap ID that goes with this query.

##### Return values

timestamp —

$pull_trigger_field_value

#### get_pull_offset()

class-object-sync-sf-salesforce-pull.php : 866

Determine the offset for the SOQL query to run

`private get_pull_offset(string $type, object $soql[, bool $reset = false ]) : mixed`

##### Parameters

$type : string

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

$soql : object

  the SOQL object.

$reset : bool = false

  whether to reset the offset.

##### Return values

mixed —

#### get_pull_query()

class-object-sync-sf-salesforce-pull.php : 731

Given a SObject type name, build an SOQL query to include all fields for all fieldmaps mapped to that SObject.

`private get_pull_query(string $type[, array<string|int, mixed> $salesforce_mapping = array() ][, bool $force_current_offset = false ]) : Object_Sync_Sf_Salesforce_Select_Query`

##### Parameters

$type : string

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

$salesforce_mapping : array<string|int, mixed> = array()

  the fieldmap that maps the two object types.

$force_current_offset : bool = false

  if true, the will offset not be recalculated and will use the offset of the current query saved on the db, if present.

##### Tags

see
  Object_Sync_Sf_Mapping::get_mapped_fields
see
  Object_Sync_Sf_Mapping::get_mapped_record_types

##### Return values

Object_Sync_Sf_Salesforce_Select_Query —

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

#### get_synced_object()

class-object-sync-sf-salesforce-pull.php : 1558

Generate the synced_object array

`private get_synced_object(array<string|int, mixed> $object, array<string|int, mixed> $mapping_object, array<string|int, mixed> $salesforce_mapping) : array<string|int, mixed>`

##### Parameters

$object : array<string|int, mixed>

  The data for the Salesforce object.

$mapping_object : array<string|int, mixed>

  The data for the mapping object between the individual Salesforce and WordPress items.

$salesforce_mapping : array<string|int, mixed>

  The data for the fieldmap between the object types.

##### Return values

array<string|int, mixed> —

$synced_object The combined array of these items. It allows for filtering of, at least, the mapping_object.

#### get_updated_records()

class-object-sync-sf-salesforce-pull.php : 345

Pull updated records from Salesforce and place them in the queue.

`private get_updated_records() : mixed`

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.

##### Return values

mixed —

#### increment_current_type_datetime()

class-object-sync-sf-salesforce-pull.php : 2214

Increment the currently running query's datetime

`private increment_current_type_datetime(string $type[, timestamp $next_query_modified_date = '' ][, int $fieldmap_id = '' ]) : mixed`

##### Parameters

$type : string

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

$next_query_modified_date : timestamp = ''

  the last record's modified datetime, or the current time if there isn't one.

$fieldmap_id : int = ''

  is the fieldmap ID that goes with this query.

##### Return values

mixed —

#### is_pull_allowed()

class-object-sync-sf-salesforce-pull.php : 2260

Find out if pull is allowed for this record

`private is_pull_allowed(string $object_type, array<string|int, mixed> $object, string $sf_sync_trigger, array<string|int, mixed> $salesforce_mapping, array<string|int, mixed> $map_sync_triggers) : bool`

##### Parameters

$object_type : string

  Salesforce object type.

$object : array<string|int, mixed>

  Array of the salesforce object's data.

$sf_sync_trigger : string

  The current operation's trigger.

$salesforce_mapping : array<string|int, mixed>

  the fieldmap that maps the two object types.

$map_sync_triggers : array<string|int, mixed>

  the triggers that are enabled.

##### Return values

bool —

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

#### parse_error_message()

class-object-sync-sf-salesforce-pull.php : 2175

Format the error message

`private parse_error_message(array<string|int, mixed> $result[, string $default_message = '' ]) : string`

##### Parameters

$result : array<string|int, mixed>

  from the WordPress class.

$default_message : string = ''

  if there is one.

##### Return values

string —

$message what is getting stored.

#### respond_to_salesforce_merge()

class-object-sync-sf-salesforce-pull.php : 1007

Respond to Salesforce merge events This means we update the mapping object to contain the new Salesforce Id, and pull its data

`private respond_to_salesforce_merge(string $object_type, array<string|int, mixed> $merged_record) : mixed`

##### Parameters

$object_type : string

  what type of Salesforce object it is.

$merged_record : array<string|int, mixed>

  the record that was merged.

##### Return values

mixed —

#### update_called_from_salesforce()

class-object-sync-sf-salesforce-pull.php : 1914

Update records in WordPress from a Salesforce pull

`private update_called_from_salesforce(string $sf_sync_trigger, array<string|int, mixed> $synced_object, array<string|int, mixed> $params, string $wordpress_id_field_name, int $seconds) : array<string|int, mixed>`

##### Parameters

$sf_sync_trigger : string

  The current operation's trigger.

$synced_object : array<string|int, mixed>

  Combined data for fieldmap, mapping object, and Salesforce object data.

$params : array<string|int, mixed>

  Array of mapped key value pairs between WordPress and Salesforce fields.

$wordpress_id_field_name : string

  The name of the ID field for this particular WordPress object type.

$seconds : int

  Timeout for the transient value to determine the direction for a sync.

##### Tags

throws
  Object_Sync_Sf_Exception

  Exception $e.

##### Return values

array<string|int, mixed> —

$results Currently this contains an array of log entries for each attempt.

## Search results