### camel-salesforce

The http://camel.apache.org/salesforce.html[salesforce,window=_blank]
component provides producer and consumer endpoints to communicate with http://www.salesforce.com/[Salesforce,window=_blank].

In order to use the component, you will need a valid Salesforce account together with credentials for accessing the Salesforce API:

* Client ID
* Client Secret
* Password
* Username

You'll want to generate the necessary Salesforce DTO objects before starting. This can be automated with the https://github.com/apache/camel/tree/master/components/camel-salesforce/camel-salesforce-maven-plugin[Camel Salesforce Maven plugin,window=_blank].

[options="nowrap"]
mvn camel-salesforce:generate -DcamelSalesforce.clientId=<clientid> -DcamelSalesforce.clientSecret=<clientsecret> -DcamelSalesforce.userName=<username> -DcamelSalesforce.password=<password>

This example queries Salesforce 'Opportunity' objects.

[source,java,options="nowrap"]
----
SalesforceLoginConfig loginConfig = new SalesforceLoginConfig();
loginConfig.setClientId("your-client-id");
loginConfig.setPassword("your-password");
loginConfig.setClientSecret("your-client-secret");
loginConfig.setUserName("your-username");

SalesforceComponent component = new SalesforceComponent();
// The package path to the generated DTO classes
component.setPackages("org.wildfly.camel.test.salesforce.dto");
component.setLoginConfig(loginConfig);

CamelContext camelctx = new DefaultCamelContext();
camelctx.addComponent("salesforce",  component);
camelctx.addRoutes(new RouteBuilder() {
    @Override
    public void configure() throws Exception {
        from("direct:query")
        .to("salesforce:query?sObjectQuery=SELECT id,name from Opportunity&sObjectClass=" + QueryRecordsOpportunity.class.getName())
        .to("log:salesforce?showAll=true");
    }
});

camelctx.start();

ProducerTemplate producer = ctx.createProducerTemplate();
QueryRecordsOpportunity queryRecords = producer.requestBody("direct:query", null, QueryRecordsOpportunity.class);
----
