Package com.avoka.component.salesforce
Class SalesForceClient
java.lang.Object
com.avoka.component.salesforce.SalesForceClient
- Direct Known Subclasses:
SalesForceClient
Provides a SalesForce service client class
See the Force.com REST API Developer's Guide for online resources.
Groovy Example
The example below illustrates how to create a SalesForceClient object using service parameters for configuration.
import com.avoka.component.salesforce.SalesForceClient import com.avoka.component.salesforce.service.Query def username = serviceParameters["SalesForce Username"] def passwordToken = serviceParameters["SalesForce Password Security Token"] def clientId = serviceParameters["SalesForce Client Id"] def clientSecret = serviceParameters["SalesForce Client Secret"] def loginServerUrl = serviceParameters["SalesForce Login Server URL"] // Create a SalesForce client using the service params with the configured connection details def salesForceClient = new SalesForceClient(username, passwordToken, clientId, clientSecret, loginServerUrl) // Use the client to query SalesForce using a pre-configured SQL Query def query = salesForceClient.getQuery() def selectQuery = serviceParameters["SalesForce Select Query"] def queryResult = query.getOperation(selectQuery)
- Since:
- 3.6.5
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetQuery()
Return a Query SalesForce service.Return the SalesForce Connection.Return a SObject SalesForce service.void
setSalesForceConnection
(SalesForceConnection salesForceConnection) Set the SalesForce Connection.toString()
Return a string representation of the object.
-
Constructor Details
-
SalesForceClient
public SalesForceClient(String username, String passwordSecurityToken, String consumerKey, String consumerSecret, String loginServerURL) throws SalesForceException Create a SalesForce client with the provided connection details.- Parameters:
username
- the SalesForce login username (required)passwordSecurityToken
- the SalesForce password security token, appended together (required)consumerKey
- the SalesForce consumer key (required)consumerSecret
- the SharePoint consumer secret (required)loginServerURL
- the SalesForce login server URL (required)- Throws:
SalesForceException
- in case of SalesForce error response during authentication
-
SalesForceClient
public SalesForceClient()Create a SalesForceClient object without a SalesForceConnection.- Since:
- 4.2.0
-
-
Method Details
-
getSalesForceConnection
Return the SalesForce Connection.- Returns:
- the SalesForce Connection
- Since:
- 4.2.0
-
setSalesForceConnection
Set the SalesForce Connection.- Parameters:
salesForceConnection
- the SalesForce Connection- Since:
- 4.2.0
-
getSObject
Return a SObject SalesForce service. The SObject service can perform operations on a given Object in the SalesForce systemGroovy Example
The Groovy script example below illustrates using the
SalesForceClient
object to create anSObject
SalesForce service object. In this example configuration Service Parameters are accessed via theserviceParameters
array.import com.avoka.component.salesforce.SalesForceClient import com.avoka.component.salesforce.service.SObject def username = serviceParameters["SalesForce Username"] def passwordToken = serviceParameters["SalesForce Password Security Token"] def clientId = serviceParameters["SalesForce Client Id"] def clientSecret = serviceParameters["SalesForce Client Secret"] def loginServerUrl = serviceParameters["SalesForce Login Server URL"] def contactId = serviceParameters["Contact ID"] // Create a SalesForce client using the service params with the configured connection details def salesForceClient = new SalesForceClient(username, passwordToken, clientId, clientSecret, loginServerUrl) // Create a SObject service def sObject = salesForceClient.getSObject() // Get a contact from SalesForce returned as a JSON string - The contact ID must be known def jsonData = sObject.getOperation("Contact", contactId)
- Returns:
- a SObject SalesForce service.
-
getQuery
Return a Query SalesForce service. The Query service can perform data lookups using the SalesForce SOQL query languageGroovy Example
The Groovy script example below illustrates using the
SalesForceClient
object to create aQuery
SalesForce service object. In this example configuration Service Parameters are accessed via theserviceParameters
array.import com.avoka.component.salesforce.SalesForceClient import com.avoka.component.salesforce.service.Query def username = serviceParameters["SalesForce Username"] def passwordToken = serviceParameters["SalesForce Password Security Token"] def clientId = serviceParameters["SalesForce Client Id"] def clientSecret = serviceParameters["SalesForce Client Secret"] def loginServerUrl = serviceParameters["SalesForce Login Server URL"] // Create a SalesForce client using the service params with the configured connection details def salesForceClient = new SalesForceClient(username, passwordToken, clientId, clientSecret, loginServerUrl) // Create a Query service def query = salesForceClient.getQuery() // Get a contact with Account details from SalesForce returned as a JSON string - The contact email address is used for the lookup def jsonData = query.getOperation("SELECT id,firstname,lastname,phone,email,a.name,a.industry FROM contact c, c.account a WHERE c.email='[email protected]'")
- Returns:
- a Query SalesForce service.
-
toString
Return a string representation of the object.
-