Menu

## Object_Sync_Sf_Salesforce
in package

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

Object_Sync_Sf_Salesforce class.

### Table of Contents

$authorize_path : string
  Path for the Salesforce authorize URL
$callback_url : string
  Callback URL for the Salesforce API
$consumer_key : string
  Salesforce consumer key
$consumer_secret : string
  Salesforce consumer secret
$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
$login_url : string
  Login URL for the Salesforce API
$option_prefix : string
  The plugin's prefix when saving options to the database
$options : array<string|int, mixed>
  API call options
$refresh_code : int
  API refresh return code
$response : array<string|int, mixed>
  API response from Salesforce
$rest_api_version : string
  REST API version for Salesforce
$schedulable_classes : array<string|int, mixed>
  Array of what classes in the plugin can be scheduled to occur with `wp_cron` events
$slug : string
  The plugin's slug so we can include it when necessary
$success_codes : array<string|int, mixed>
  API success return codes
$success_or_refresh_codes : array<string|int, mixed>
  API success or refresh return codes
$token_path : string
  Path for the Salesforce token URL
$version : string
  Current version of the plugin
$wordpress : object
  Object_Sync_Sf_WordPress class
__construct() : mixed
  Constructor for Salesforce class
analytics_api() : object
  Make a call to the Analytics API. Part of core API calls.
api_call() : mixed
  Make a call to the Salesforce REST API.
convert_id() : string
  Converts a 15-character case-sensitive Salesforce ID to 18-character case-insensitive ID. If input is not 15-characters, return input unaltered.
get_access_token() : mixed
  Get the access token.
get_api_endpoint() : string
  Get the API end point for a given type of the API.
get_api_versions() : mixed
  Get REST API versions available on this Salesforce organization This is not an authenticated call, so it would not be a helpful test
get_authorization_code() : mixed
  OAuth step 1: Redirect to Salesforce and request and authorization code.
get_deleted() : mixed
  Retrieves the list of individual objects that have been deleted within the given timespan for a specified object type.
get_identity() : array<string|int, mixed>
  Return the Salesforce identity, which is stored in a variable.
get_instance_url() : mixed
  Get the SF instance URL. Useful for linking to objects.
get_record_type_id_by_developer_name() : string
  Given a DeveloperName and SObject Name, return the SFID of the corresponding RecordType. DeveloperName doesn't change between Salesforce environments, so it's safer to rely on compared to SFID.
get_sobject_type() : string
  Given a Salesforce ID, return the corresponding SObject name. (Based on keyPrefix from object definition,
get_updated() : array<string|int, mixed>
  Return a list of SFIDs for the given object, which have been created or updated in the given timeframe. Part of core API calls.
is_authorized() : mixed
  Determine if this SF instance is fully configured.
list_resources() : array<string|int, mixed>
  Return a list of available resources for the configured API version. Part of core API calls.
object_create() : array<string|int, mixed>
  Create a new object of the given type. Part of core API calls.
object_delete() : array<string|int, mixed>
  Delete a Salesforce object. Part of core API calls
object_describe() : array<string|int, mixed>
  Retrieve all the metadata for an object. Part of core API calls.
object_read() : object
  Return a full loaded Salesforce object. Part of core API calls.
object_readby_external_id() : object
  Return a full loaded Salesforce object from External ID. Part of core API calls.
object_update() : array<string|int, mixed>
  Update an existing object. Part of core API calls.
object_upsert() : array<string|int, mixed>
  Create new records or update existing records.
objects() : array<string|int, mixed>
  Available objects and their metadata for your organization's data.
query() : array<string|int, mixed>
  Use SOQL to get objects based on query string. Part of core API calls.
request_token() : mixed
  OAuth step 2: Exchange an authorization code for an access token.
run_analytics_report() : object
  Run a specific Analytics report. Part of core API calls.
api_http_request() : array<string|int, mixed>
  Private helper to issue an SF API request.
get_refresh_token() : mixed
  Get refresh token.
http_request() : array<string|int, mixed>
  Make the HTTP request. Wrapper around curl().
refresh_token() : mixed
  Refresh access token based on the refresh token. Updates session variable.
set_access_token() : mixed
  Set the access token.
set_identity() : mixed
  Retrieve and store the Salesforce identity given an ID url.
set_instance_url() : mixed
  Set the SF instance URL.
set_refresh_token() : mixed
  Set refresh token.
cache_expiration() : mixed
  If there is a WordPress setting for how long to keep the cache, return it and set the object property Otherwise, return seconds in 24 hours.

### Properties

#### $authorize_path

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

Path for the Salesforce authorize URL

`public string $authorize_path`

#### $callback_url

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

Callback URL for the Salesforce API

`public string $callback_url`

#### $consumer_key

class-object-sync-sf-salesforce.php : 112

Salesforce consumer key

`public string $consumer_key`

#### $consumer_secret

class-object-sync-sf-salesforce.php : 119

Salesforce consumer secret

`public string $consumer_secret`

#### $debug

class-object-sync-sf-salesforce.php : 154

Whether the plugin is in debug mode

`public bool $debug`

#### $file

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

The main plugin file

`public string $file`

#### $logging

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

Object_Sync_Sf_Logging class

`public object $logging`

#### $login_credentials

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

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

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

#### $login_url

class-object-sync-sf-salesforce.php : 98

Login URL for the Salesforce API

`public string $login_url`

#### $option_prefix

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

The plugin's prefix when saving options to the database

`public string $option_prefix`

#### $options

class-object-sync-sf-salesforce.php : 126

API call options

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

#### $refresh_code

class-object-sync-sf-salesforce.php : 140

API refresh return code

`public int $refresh_code`

#### $response

class-object-sync-sf-salesforce.php : 161

API response from Salesforce

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

#### $rest_api_version

class-object-sync-sf-salesforce.php : 105

REST API version for Salesforce

`public string $rest_api_version`

#### $schedulable_classes

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

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

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

#### $slug

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

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

`public string $slug`

#### $success_codes

class-object-sync-sf-salesforce.php : 133

API success return codes

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

#### $success_or_refresh_codes

class-object-sync-sf-salesforce.php : 147

API success or refresh return codes

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

#### $token_path

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

Path for the Salesforce token URL

`public string $token_path`

#### $version

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

Current version of the plugin

`public string $version`

#### $wordpress

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

Object_Sync_Sf_WordPress class

`public object $wordpress`

### Methods

#### __construct()

class-object-sync-sf-salesforce.php : 166

Constructor for Salesforce class

`public __construct() : mixed`

##### Return values

mixed —

#### analytics_api()

class-object-sync-sf-salesforce.php : 1081

Make a call to the Analytics API. Part of core API calls.

`public analytics_api(string $name, string $id[, string $route = '' ][, array<string|int, mixed> $params = array() ][, string $method = 'GET' ]) : object`

##### Parameters

$name : string

  Object type name, E.g., Report.

$id : string

  Salesforce id of the object.

$route : string = ''

  What comes after the ID? E.g. instances, ?includeDetails=True.

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

  Params to put with the request.

$method : string = 'GET'

  GET or POST.

##### Return values

object —

Object of the requested Salesforce object.

#### api_call()

class-object-sync-sf-salesforce.php : 281

Make a call to the Salesforce REST API.

`public api_call(string $path[, array<string|int, mixed> $params = array() ][, string $method = 'GET' ][, array<string|int, mixed> $options = array() ][, string $type = 'rest' ]) : mixed`

##### Parameters

$path : string

  Path to resource.

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

  Parameters to provide.

$method : string = 'GET'

  Method to initiate the call, such as GET or POST. Defaults to GET.

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

  Any method can supply options for the API call, and they'll be preserved as far as the curl request. They get merged with the class options.

$type : string = 'rest'

  Type of call. Defaults to 'rest' - currently we don't support other types. Other exammple in Drupal is 'apexrest'.

##### Tags

throws
  Object_Sync_Sf_Exception

  The plugin's exception class.

##### Return values

mixed —

The requested response.

#### convert_id()

class-object-sync-sf-salesforce.php : 208

Converts a 15-character case-sensitive Salesforce ID to 18-character case-insensitive ID. If input is not 15-characters, return input unaltered.

`public static convert_id(string $sf_id_15) : string`

##### Parameters

$sf_id_15 : string

  15-character case-sensitive Salesforce ID.

##### Return values

string —

18-character case-insensitive Salesforce ID

#### get_access_token()

class-object-sync-sf-salesforce.php : 694

Get the access token.

`public get_access_token() : mixed`

##### Return values

mixed —

#### get_api_endpoint()

class-object-sync-sf-salesforce.php : 661

Get the API end point for a given type of the API.

`public get_api_endpoint([string $api_type = 'rest' ]) : string`

##### Parameters

$api_type : string = 'rest'

  E.g., rest, partner, enterprise.

##### Return values

string —

Complete URL endpoint for API access.

#### get_api_versions()

class-object-sync-sf-salesforce.php : 262

Get REST API versions available on this Salesforce organization This is not an authenticated call, so it would not be a helpful test

`public get_api_versions() : mixed`

##### Tags

deprecated

  since version 2.2.0; will be removed in 3.0.0.

##### Return values

mixed —

#### get_authorization_code()

class-object-sync-sf-salesforce.php : 811

OAuth step 1: Redirect to Salesforce and request and authorization code.

`public get_authorization_code() : mixed`

##### Return values

mixed —

#### get_deleted()

class-object-sync-sf-salesforce.php : 1214

Retrieves the list of individual objects that have been deleted within the given timespan for a specified object type.

`public get_deleted(string $type, string $start_date, string $end_date) : mixed`

##### Parameters

$type : string

  Object type name, E.g., Contact, Account.

$start_date : string

  Start date to check for deleted objects (in ISO 8601 format).

$end_date : string

  End date to check for deleted objects (in ISO 8601 format).

##### Return values

mixed —

$result

#### get_identity()

class-object-sync-sf-salesforce.php : 804

Return the Salesforce identity, which is stored in a variable.

`public get_identity() : array<string|int, mixed>`

##### Return values

array<string|int, mixed> —

Returns false if no identity has been stored.

#### get_instance_url()

class-object-sync-sf-salesforce.php : 678

Get the SF instance URL. Useful for linking to objects.

`public get_instance_url() : mixed`

##### Return values

mixed —

#### get_record_type_id_by_developer_name()

class-object-sync-sf-salesforce.php : 1278

Given a DeveloperName and SObject Name, return the SFID of the corresponding RecordType. DeveloperName doesn't change between Salesforce environments, so it's safer to rely on compared to SFID.

`public get_record_type_id_by_developer_name(string $name, string $devname[, bool $reset = false ]) : string`

##### Parameters

$name : string

  Object type name, E.g., Contact, Account.

$devname : string

  RecordType DeveloperName, e.g. Donation, Membership, etc.

$reset : bool = false

  whether this is resetting the cache.

##### Return values

string —

SFID The Salesforce ID of the given Record Type, or null.

#### get_sobject_type()

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

Given a Salesforce ID, return the corresponding SObject name. (Based on keyPrefix from object definition,

`public get_sobject_type(string $sf_id) : string`

##### Parameters

$sf_id : string

  15- or 18-character Salesforce ID.

##### Tags

see
  https://developer.salesforce.com/forums/?id=906F0000000901ZIAQ

  )

##### Return values

string —

sObject name, e.g. "Account", "Contact", "my__Custom_Object__c" or false if no match could be found.

#### get_updated()

class-object-sync-sf-salesforce.php : 1251

Return a list of SFIDs for the given object, which have been created or updated in the given timeframe. Part of core API calls.

`public get_updated(string $type[, int $start = null ][, int $end = null ]) : array<string|int, mixed>`

##### Parameters

$type : string

  Object type name, E.g., Contact, Account.

$start : int = null

  unix timestamp for older timeframe for updates. Defaults to "-29 days" if empty.

$end : int = null

  unix timestamp for end of timeframe for updates. Defaults to now if empty.

##### Tags

see
  https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_getupdated.htm

##### Return values

array<string|int, mixed> —

return array has 2 indexes: "ids": a list of SFIDs of those records which have been created or updated in the given timeframe. "latestDateCovered": ISO 8601 format timestamp (UTC) of the last date covered in the request.

#### is_authorized()

class-object-sync-sf-salesforce.php : 252

Determine if this SF instance is fully configured.

`public is_authorized() : mixed`

##### Return values

mixed —

#### list_resources()

class-object-sync-sf-salesforce.php : 1227

Return a list of available resources for the configured API version. Part of core API calls.

`public list_resources() : array<string|int, mixed>`

##### Return values

array<string|int, mixed> —

Associative array keyed by name with a URI value.

#### object_create()

class-object-sync-sf-salesforce.php : 986

Create a new object of the given type. Part of core API calls.

`public object_create(string $name, array<string|int, mixed> $params) : array<string|int, mixed>`

##### Parameters

$name : string

  Object type name, E.g., Contact, Account, etc.

$params : array<string|int, mixed>

  Values of the fields to set for the object.

##### Return values

array<string|int, mixed> —

json: {"id":"00190000001pPvHAAU","success":true,"errors":[]} code: 201 data: "id" : "00190000001pPvHAAU", "success" : true "errors" : [ ], from_cache: cached: is_redo:

#### object_delete()

class-object-sync-sf-salesforce.php : 1197

Delete a Salesforce object. Part of core API calls

`public object_delete(string $name, string $id) : array<string|int, mixed>`

##### Parameters

$name : string

  Object type name, E.g., Contact, Account.

$id : string

  Salesforce id of the object.

##### Return values

array<string|int, mixed> —

#### object_describe()

class-object-sync-sf-salesforce.php : 944

Retrieve all the metadata for an object. Part of core API calls.

`public object_describe(string $name[, bool $reset = false ]) : array<string|int, mixed>`

##### Parameters

$name : string

  Object type name, E.g., Contact, Account, etc.

$reset : bool = false

  Whether to reset the cache and retrieve a fresh version from Salesforce.

##### Return values

array<string|int, mixed> —

All the metadata for an object, including information about each field, URLs, and child relationships.

#### object_read()

class-object-sync-sf-salesforce.php : 1067

Return a full loaded Salesforce object. Part of core API calls.

`public object_read(string $name, string $id[, array<string|int, mixed> $options = array() ]) : object`

##### Parameters

$name : string

  Object type name, E.g., Contact, Account.

$id : string

  Salesforce id of the object.

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

  Optional options to pass to the API call.

##### Return values

object —

Object of the requested Salesforce object.

#### object_readby_external_id()

class-object-sync-sf-salesforce.php : 1186

Return a full loaded Salesforce object from External ID. Part of core API calls.

`public object_readby_external_id(string $name, string $field, string $value[, array<string|int, mixed> $options = array() ]) : object`

##### Parameters

$name : string

  Object type name, E.g., Contact, Account.

$field : string

  Salesforce external id field name.

$value : string

  Value of external id.

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

  Optional options to pass to the API call.

##### Return values

object —

Object of the requested Salesforce object.

#### object_update()

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

Update an existing object. Part of core API calls.

`public object_update(string $name, string $id, array<string|int, mixed> $params) : array<string|int, mixed>`

##### Parameters

$name : string

  Object type name, E.g., Contact, Account.

$id : string

  Salesforce id of the object.

$params : array<string|int, mixed>

  Values of the fields to set for the object.

##### Return values

array<string|int, mixed> —

json: {"success":true,"body":""} code: 204 data: success: 1 body: from_cache: cached: is_redo:

#### object_upsert()

class-object-sync-sf-salesforce.php : 1015

Create new records or update existing records.

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

The new records or updated records are based on the value of the specified field. If the value is not unique, REST API returns a 300 response with the list of matching records. Part of core API calls.

##### Parameters

$name : string

  Object type name, E.g., Contact, Account.

$key : string

  The field to check if this record should be created or updated.

$value : string

  The value for this record of the field specified for $key.

$params : array<string|int, mixed>

  Values of the fields to set for the object.

##### Return values

array<string|int, mixed> —

json: {"id":"00190000001pPvHAAU","success":true,"errors":[]} code: 201 data: "id" : "00190000001pPvHAAU", "success" : true "errors" : [ ], from_cache: cached: is_redo:

#### objects()

class-object-sync-sf-salesforce.php : 882

Available objects and their metadata for your organization's data.

`public objects([array<string|int, mixed> $conditions = array('updateable' => true, 'triggerable' => true) ][, bool $reset = false ]) : array<string|int, mixed>`

part of core API calls. this call does require authentication, and the basic url it becomes is like this: https://instance.salesforce.com/services/data/v#.0/sobjects note: updateable is really how the api spells it

##### Parameters

$conditions : array<string|int, mixed> = array('updateable' => true, 'triggerable' => true)

  Associative array of filters to apply to the returned objects. Filters are applied after the list is returned from Salesforce.

$reset : bool = false

  Whether to reset the cache and retrieve a fresh version from Salesforce.

##### Return values

array<string|int, mixed> —

Available objects and metadata.

#### query()

class-object-sync-sf-salesforce.php : 919

Use SOQL to get objects based on query string. Part of core API calls.

`public query(string $query[, array<string|int, mixed> $options = array() ][, bool $all = false ][, bool $explain = false ]) : array<string|int, mixed>`

##### Parameters

$query : string

  The SOQL query.

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

  Allow for the query to have options based on what the user needs from it, ie caching, read/write, etc.

$all : bool = false

  Whether this should get all results for the query.

$explain : bool = false

  If set, Salesforce will return feedback on the query performance.

##### Return values

array<string|int, mixed> —

Array of Salesforce objects that match the query.

#### request_token()

class-object-sync-sf-salesforce.php : 829

OAuth step 2: Exchange an authorization code for an access token.

`public request_token(string $code) : mixed`

##### Parameters

$code : string

  Code from Salesforce.

##### Tags

throws
  Object_Sync_Sf_Exception

  The plugin's exception class.

##### Return values

mixed —

#### run_analytics_report()

class-object-sync-sf-salesforce.php : 1098

Run a specific Analytics report. Part of core API calls.

`public run_analytics_report(string $id[, bool $async = true ][, bool $clear_cache = false ][, array<string|int, mixed> $params = array() ][, string $method = 'GET' ][, string $report_cache_expiration = '' ][, bool $cache_instance = true ][, string $instance_cache_expiration = '' ]) : object`

##### Parameters

$id : string

  Salesforce id of the object.

$async : bool = true

  Whether the report is asynchronous.

$clear_cache : bool = false

  Whether the cache is being cleared.

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

  Params to put with the request.

$method : string = 'GET'

  GET or POST.

$report_cache_expiration : string = ''

  How long to keep the report's cache result around for.

$cache_instance : bool = true

  Whether to cache the instance results.

$instance_cache_expiration : string = ''

  How long to keep the instance's cache result around for.

##### Return values

object —

Object of the requested Salesforce object.

#### api_http_request()

class-object-sync-sf-salesforce.php : 341

Private helper to issue an SF API request.

`protected api_http_request(string $path, array<string|int, mixed> $params, string $method[, array<string|int, mixed> $options = array() ][, string $type = 'rest' ]) : array<string|int, mixed>`

This method is the only place where we read to or write from the cache

##### Parameters

$path : string

  Path to resource.

$params : array<string|int, mixed>

  Parameters to provide.

$method : string

  Method to initiate the call, such as GET or POST. Defaults to GET.

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

  This is the options array from the api_call method. This is where it gets merged with $this->options.

$type : string = 'rest'

  Type of call. Defaults to 'rest' - currently we don't support other types. Other exammple in Drupal is 'apexrest'.

##### Return values

array<string|int, mixed> —

The requested data.

#### get_refresh_token()

class-object-sync-sf-salesforce.php : 711

Get refresh token.

`protected get_refresh_token() : mixed`

##### Return values

mixed —

#### http_request()

class-object-sync-sf-salesforce.php : 484

Make the HTTP request. Wrapper around curl().

`protected http_request(string $url, array<string|int, mixed> $data[, array<string|int, mixed> $headers = array() ][, string $method = 'GET' ][, array<string|int, mixed> $options = array() ]) : array<string|int, mixed>`

##### Parameters

$url : string

  Path to make request from.

$data : array<string|int, mixed>

  The request body.

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

  Request headers to send as name => value.

$method : string = 'GET'

  Method to initiate the call, such as GET or POST. Defaults to GET.

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

  This is the options array from the api_http_request method.

##### Return values

array<string|int, mixed> —

Salesforce response object.

#### refresh_token()

class-object-sync-sf-salesforce.php : 733

Refresh access token based on the refresh token. Updates session variable.

`protected refresh_token() : mixed`

Todo: figure out how to do this as part of the schedule class 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. but it could be a performance boost to do it at scheduleable intervals instead.

##### Tags

throws
  Object_Sync_Sf_Exception

  The plugin's exception class.

##### Return values

mixed —

#### set_access_token()

class-object-sync-sf-salesforce.php : 704

Set the access token.

`protected set_access_token(string $token) : mixed`

It is stored in session.

##### Parameters

$token : string

  Access token from Salesforce.

##### Return values

mixed —

#### set_identity()

class-object-sync-sf-salesforce.php : 785

Retrieve and store the Salesforce identity given an ID url.

`protected set_identity(string $id) : mixed`

##### Parameters

$id : string

  Identity URL.

##### Tags

throws
  Object_Sync_Sf_Exception

  The plugin's exception class.

##### Return values

mixed —

#### set_instance_url()

class-object-sync-sf-salesforce.php : 687

Set the SF instance URL.

`protected set_instance_url(string $url) : mixed`

##### Parameters

$url : string

  URL to set.

##### Return values

mixed —

#### set_refresh_token()

class-object-sync-sf-salesforce.php : 720

Set refresh token.

`protected set_refresh_token(string $token) : mixed`

##### Parameters

$token : string

  Refresh token from Salesforce.

##### Return values

mixed —

#### cache_expiration()

class-object-sync-sf-salesforce.php : 1306

If there is a WordPress setting for how long to keep the cache, return it and set the object property Otherwise, return seconds in 24 hours.

`private cache_expiration() : mixed`

##### Return values

mixed —

## Search results