$response
$response :
Ability to authorize and communicate with the Salesforce REST API. This class can make read and write calls to Salesforce, and also cache the responses in WordPress.
__construct(string $consumer_key, string $consumer_secret, string $login_url, string $callback_url, string $authorize_path, string $token_path, string $rest_api_version, object $wordpress, string $slug, object $logging, array $schedulable_classes, string $option_prefix = '')
Constructor which initializes the Salesforce APIs.
| string | $consumer_key | Salesforce key to connect to your Salesforce instance. |
| string | $consumer_secret | Salesforce secret to connect to your Salesforce instance. |
| string | $login_url | Login URL for Salesforce auth requests - differs for production and sandbox |
| string | $callback_url | WordPress URL where Salesforce should send you after authentication |
| string | $authorize_path | Oauth path that Salesforce wants |
| string | $token_path | Path Salesforce uses to give you a token |
| string | $rest_api_version | What version of the Salesforce REST API to use |
| object | $wordpress | Object for doing things to WordPress - retrieving data, cache, etc. |
| string | $slug | Slug for this plugin. Can be used for file including, especially |
| object | $logging | Logging object for this plugin. |
| array | $schedulable_classes | array of classes that can have scheduled tasks specific to them |
| string | $option_prefix | Option prefix for this plugin. Used for getting and setting options, actions, etc. |
convert_id(string $sf_id_15) : string
Converts a 15-character case-sensitive Salesforce ID to 18-character case-insensitive ID. If input is not 15-characters, return input unaltered.
| string | $sf_id_15 | 15-character case-sensitive Salesforce ID |
18-character case-insensitive Salesforce ID
get_sobject_type(string $sf_id) : string
Given a Salesforce ID, return the corresponding SObject name. (Based on keyPrefix from object definition, @see https://developer.salesforce.com/forums/?id=906F0000000901ZIAQ )
| string | $sf_id | 15- or 18-character Salesforce ID |
sObject name, e.g. "Account", "Contact", "my__Custom_Object__c" or FALSE if no match could be found.
is_authorized()
Determine if this SF instance is fully configured.
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_api_versions()
Get REST API versions available on this Salesforce organization This is not an authenticated call, so it would not be a helpful test
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 1293api_call(string $path, array $params = array(), string $method = 'GET', array $options = array(), string $type = 'rest') : mixed
Make a call to the Salesforce REST API.
| string | $path | Path to resource. |
| array | $params | Parameters to provide. |
| string | $method | Method to initiate the call, such as GET or POST. Defaults to GET. |
| array | $options | 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 |
| string | $type | Type of call. Defaults to 'rest' - currently we don't support other types. Other exammple in Drupal is 'apexrest' |
The requested response.
get_api_endpoint(string $api_type = 'rest') : string
Get the API end point for a given type of the API.
| string | $api_type | E.g., rest, partner, enterprise. |
Complete URL endpoint for API access.
get_instance_url()
Get the SF instance URL. Useful for linking to objects.
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_access_token()
Get the access token.
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_identity() : array
Return the Salesforce identity, which is stored in a variable.
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 no identity has been stored.
get_authorization_code()
OAuth step 1: Redirect to Salesforce and request and authorization code.
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 1293request_token(string $code)
OAuth step 2: Exchange an authorization code for an access token.
| string | $code | Code from Salesforce. |
objects(array $conditions = array('updateable' => true, 'triggerable' => true), boolean $reset = false) : array
Available objects and their metadata for your organization's data.
| array | $conditions | Associative array of filters to apply to the returned objects. Filters are applied after the list is returned from Salesforce. |
| boolean | $reset | Whether to reset the cache and retrieve a fresh version from Salesforce. |
Available objects and metadata.
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
updateable is really how the api spells it
query(string $query, array $options = array(), boolean $all = false, boolean $explain = false) : array
Use SOQL to get objects based on query string.
| string | $query | The SOQL query. |
| array | $options | Allow for the query to have options based on what the user needs from it, ie caching, read/write, etc. |
| boolean | $all | Whether this should get all results for the query |
| boolean | $explain | If set, Salesforce will return feedback on the query performance |
Array of Salesforce objects that match the query.
part of core API calls
object_describe(string $name, boolean $reset = false) : array
Retrieve all the metadata for an object.
| string | $name | Object type name, E.g., Contact, Account, etc. |
| boolean | $reset | Whether to reset the cache and retrieve a fresh version from Salesforce. |
All the metadata for an object, including information about each field, URLs, and child relationships.
part of core API calls
object_create(string $name, array $params) : array
Create a new object of the given type.
| string | $name | Object type name, E.g., Contact, Account, etc. |
| array | $params | Values of the fields to set for the object. |
json: {"id":"00190000001pPvHAAU","success":true,"errors":[]} code: 201 data: "id" : "00190000001pPvHAAU", "success" : true "errors" : [ ], from_cache: cached: is_redo:
part of core API calls
object_upsert(string $name, string $key, string $value, array $params) : array
Create new records or update existing records.
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.
| string | $name | Object type name, E.g., Contact, Account. |
| string | $key | The field to check if this record should be created or updated. |
| string | $value | The value for this record of the field specified for $key. |
| array | $params | Values of the fields to set for the object. |
json: {"id":"00190000001pPvHAAU","success":true,"errors":[]} code: 201 data: "id" : "00190000001pPvHAAU", "success" : true "errors" : [ ], from_cache: cached: is_redo:
part of core API calls
object_update(string $name, string $id, array $params) : array
Update an existing object.
| string | $name | Object type name, E.g., Contact, Account. |
| string | $id | Salesforce id of the object. |
| array | $params | Values of the fields to set for the object. part of core API calls |
json: {"success":true,"body":""} code: 204 data: success: 1 body: from_cache: cached: is_redo:
object_read(string $name, string $id, array $options = array()) : object
Return a full loaded Salesforce object.
| string | $name | Object type name, E.g., Contact, Account. |
| string | $id | Salesforce id of the object. |
| array | $options | Optional options to pass to the API call |
Object of the requested Salesforce object.
part of core API calls
analytics_api(string $name, string $id, string $route = '', array $params = array(), string $method = 'GET') : object
Make a call to the Analytics API
| string | $name | Object type name, E.g., Report |
| string | $id | Salesforce id of the object. |
| string | $route | What comes after the ID? E.g. instances, ?includeDetails=True |
| array | $params | Params to put with the request |
| string | $method | GET or POST |
Object of the requested Salesforce object.
part of core API calls
run_analytics_report(string $id, boolean $async = true, $clear_cache = false, array $params = array(), string $method = 'GET', $report_cache_expiration = '', $cache_instance = true, $instance_cache_expiration = '') : object
Run a specific Analytics report
| string | $id | Salesforce id of the object. |
| boolean | $async | Whether the report is asynchronous |
| $clear_cache | ||
| array | $params | Params to put with the request |
| string | $method | GET or POST |
| $report_cache_expiration | ||
| $cache_instance | ||
| $instance_cache_expiration |
Object of the requested Salesforce object.
part of core API calls
object_readby_external_id(string $name, string $field, string $value, array $options = array()) : object
Return a full loaded Salesforce object from External ID.
| string | $name | Object type name, E.g., Contact, Account. |
| string | $field | Salesforce external id field name. |
| string | $value | Value of external id. |
| array | $options | Optional options to pass to the API call |
Object of the requested Salesforce object.
part of core API calls
object_delete(string $name, string $id) : array
Delete a Salesforce object.
| string | $name | Object type name, E.g., Contact, Account. |
| string | $id | Salesforce id of the object. |
part of core API calls
get_deleted(string $type, $start_date, $end_date) : \GetDeletedResult
Retrieves the list of individual objects that have been deleted within the given timespan for a specified object type.
| string | $type | Object type name, E.g., Contact, Account. |
| $start_date | ||
| $end_date |
list_resources() : array
Return a list of available resources for the configured API version.
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 1293Associative array keyed by name with a URI value.
part of core API calls
get_updated(string $type, integer $start = null, integer $end = null) : array
Return a list of SFIDs for the given object, which have been created or updated in the given timeframe.
| string | $type | Object type name, E.g., Contact, Account. |
| integer | $start | unix timestamp for older timeframe for updates. Defaults to "-29 days" if empty. |
| integer | $end | unix timestamp for end of timeframe for updates. Defaults to now if empty |
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.
get_record_type_id_by_developer_name(string $name, string $devname, $reset = false) : 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.
| string | $name | Object type name, E.g., Contact, Account. |
| string | $devname | RecordType DeveloperName, e.g. Donation, Membership, etc. |
| $reset |
SFID The Salesforce ID of the given Record Type, or null.
api_http_request(string $path, array $params, string $method, array $options = array(), string $type = 'rest') : array
Private helper to issue an SF API request.
This method is the only place where we read to or write from the cache
| string | $path | Path to resource. |
| array | $params | Parameters to provide. |
| string | $method | Method to initiate the call, such as GET or POST. Defaults to GET. |
| array | $options | This is the options array from the api_call method This is where it gets merged with $this->options |
| string | $type | Type of call. Defaults to 'rest' - currently we don't support other types Other exammple in Drupal is 'apexrest' |
The requested data.
http_request(string $url, array $data, array $headers = array(), string $method = 'GET', array $options = array()) : array
Make the HTTP request. Wrapper around curl().
| string | $url | Path to make request from. |
| array | $data | The request body. |
| array | $headers | Request headers to send as name => value. |
| string | $method | Method to initiate the call, such as GET or POST. Defaults to GET. |
| array | $options | This is the options array from the api_http_request method |
Salesforce response object.
set_instance_url(string $url)
Set the SF instanc URL.
| string | $url | URL to set. |
set_access_token(string $token)
Set the access token.
It is stored in session.
| string | $token | Access token from Salesforce. |
get_refresh_token()
Get refresh token.
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 1293set_refresh_token(string $token)
Set refresh token.
| string | $token | Refresh token from Salesforce. |
refresh_token()
Refresh access token based on the refresh token. Updates session variable.
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.
cache_expiration()
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
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