oafasys/salesforce

There is no license information available for the latest version (v2.0.1) of this package.

Provides a service for interacting with the Salesforce Lightning API

v2.0.1 2023-01-20 14:43 UTC

This package is auto-updated.

Last update: 2024-04-20 17:19:50 UTC


README

This package provides an easy way to interface directly with the Salesforce API. It includes several common functions, as well as the logic for authentication and authorization.

Installation

composer require oafasys/salesforce

After installation, publish assets:

php artisan vendor:publish

You will need to choose the SalesforceServiceProvider from the list. This will create a new config file, salesforce.php.

Config

Your .env should include:

SALESFORCE_ACTIVE=true|false
SALESFORCE_ALERT_ESMS=true|false
SALESFORCE_ENVIRONMENT=prod|staging
SALESFORCE_ID=
SALESFORCE_SECRET=
SALESFORCE_REFRESH=
SALESFORCE_ACCESS=

Please note that, regardless of how many applications use this package, only one application should have SALESFORCE_ALERT_ESMS set to true, or the ESMs will receive multiple emails about faulty recruiting events.

Obtaining Config Values

Perhaps not surprisingly, the process by which you can obtain the necessary keys to access the API is complicated. Please check internal documentation sources for this process.

Usage

Extending the Salesforce model

You may discover that you need your own custom functions -- to do this, you can extend the Salesforce model and create your own methods there. If you find that several projects need the same custom methods, you may consider adding them to this package for universal access.

Available methods

getEvents($type, $from = NULL)

`$type is either 'recruiting' or 'engagement' $from` is an optional string that will be converted to a Carbon object to use as a starting point for the retrieval

This method returns an array of full event objects, with all available Salesforce data attached.

Please note that this returns only future events (i.e., events with a start date greater than today).

`$from applies to last modified date -- events that have not been updated since $from` will not appear in the results.

getUser($salesforce_id)

This method returns the user whose id corresponds to `$salesforce_id`.

getCampaign($salesforce_id)

This method returns the campaign whose id corresponds to `$salesforce_id`.

getObject($object, $field, $value)

This generic method returns any object of the type `$object whose $field has a value of $value`.