Salesforce Api Client


License

License

Categories

Categories

IDE Development Tools CLI User Interface
GroupId

GroupId

com.github.mideo
ArtifactId

ArtifactId

salesforce-api-client
Last Version

Last Version

0.0.4
Release Date

Release Date

Type

Type

jar
Description

Description

Salesforce Api Client
Salesforce Api Client
Project URL

Project URL

https://github.com/MideO/salesforce-api-client
Source Code Management

Source Code Management

https://github.com/MideO/salesforce-api-client

Download salesforce-api-client

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.mideo/salesforce-api-client/ -->
<dependency>
    <groupId>com.github.mideo</groupId>
    <artifactId>salesforce-api-client</artifactId>
    <version>0.0.4</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.mideo/salesforce-api-client/
implementation 'com.github.mideo:salesforce-api-client:0.0.4'
// https://jarcasting.com/artifacts/com.github.mideo/salesforce-api-client/
implementation ("com.github.mideo:salesforce-api-client:0.0.4")
'com.github.mideo:salesforce-api-client:jar:0.0.4'
<dependency org="com.github.mideo" name="salesforce-api-client" rev="0.0.4">
  <artifact name="salesforce-api-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.mideo', module='salesforce-api-client', version='0.0.4')
)
libraryDependencies += "com.github.mideo" % "salesforce-api-client" % "0.0.4"
[com.github.mideo/salesforce-api-client "0.0.4"]

Dependencies

compile (9)

Group / Artifact Type Version
com.force.api : force-wsc jar 38.0.4
com.force.api : force-apex-api jar 38.0.0
com.force.api : force-partner-api jar 38.0.0
com.force.api : force-metadata-api jar 38.0.0
com.jayway.restassured : rest-assured jar 2.9.0
junit : junit jar 4.12
org.apache.commons : commons-csv jar 1.4
commons-io : commons-io jar 2.5
org.apache.ant : ant jar 1.8.2

test (4)

Group / Artifact Type Version
org.codehaus.groovy : groovy-all jar 2.2.0
org.spockframework : spock-core jar 0.7-groovy-2.0
cglib : cglib-nodep jar 2.2
org.objenesis : objenesis jar 1.2

Project Modules

There are no modules declared in this project.

salesforce-api-client

Build Status

Maven Central

Setup dependency

JDK "1.8"

In build.gradle

Add maven url
repositories {
    mavenCentral()
}
Add dependency
dependencies {
    compile group: 'com.github.mideo', name:'salesforce-api-client', version: '0.0.2'
}
Usage
SalesforceConfig config = new SalesforceConfig("https://test.salesforce.com")
                .clientId("dfghjkl")
                .clientSecret("fdghjkl;")
                .userName("[email protected]")
                .userToken("gfhjk")
                .password("fghjkl");
SalesforceConnectionClient connectionClient = new SalesforceConnectionClient(config);
SalesforceWebServiceClient webClient = new SalesforceWebServiceClient(connectionClient);

//Create sObject from POJO
class Account {
        def name;
        def email;
        def id;
}

Account account = new Account();
account.name =  "testName bazz";
account.email =  "[email protected]";
account.id = webClient.createObject("Account", account);


//Update sObject from POJO
Account account = new Account();
account.name =  "testName2 bazzer";
account.email =  "[email protected]";
String result = webClient.updateObject("Account",account.id,  account);


//Create sObject from HashMap
Map<String,Object> logData = new HashMap<>();
logData.put("Short_Description__c","Api test"+ DateTime.now().toString());
logData.put("Description__c","test description Api test"+ DateTime.now().toString()) 
String id = webClient.createObject("Log__c", logData);

            
//Update sObject from HashMap
logData.put("Exception_Type__c","dummyEx"+ DateTime.now().toString());
result = webClient.updateObject("Log__c",id, logData);


//Retrieve Object
Map<String, Object> resultMap = webClient.retrieveObject("Case", caseId);
            
            
//Delete sObject
String result = webClient.deleteObject(contactId);

                        
//Execute Anonymous Apex 
ExecuteAnonymousResult exectueResult = webClient.executeApexBlock("System.debug('test debug message');");


//Export data
List<Map<String, String>> dataList = webClient
                                    .setPublishStatusCheckTimeout(10000)
                                    .exportDataFromTable("Account");


//Publish csv stream to sObject via bulk api
PublishResult publishResult = webClient.publishCsvToTable(csvInputStream, "Contact");

//Get published data status
String status = getPublishedDataStatus(
                        publishResult.jobInfo.getId, 
                        publishResult.batchInfo.getId
                            );
            
//Export filtered data
Map<String,String> filter = new HashMap<>();
filter.put("Product__c","DummyBox");
filter.put("Delivered",true);
List<Map<String, String>> dataList = webClient.exportDataFromTable("Order__c", filter);


//Export filtered data columns
Map<String,String> filter = new HashMap<>();
filter.put("Product__c","DummyBox");
filter.put("Delivered",true);
List<String> columns = new ArrayList<>();
columns.add("Short_Description__c");
columns.add("Description__c");
List<Map<String, String>> dataList = webClient.exportDataFromTable("Order__c", columns, filter);

Ant Tasks

Retrieving sObjects to csv 
Define config json {<sObjectName>: [<comma seperated list of columns>]}

e.g. conf.json
    {
        "Settings__c" : ["Name","Value__c"],
        "Account": ["Name","Email"]
    }
In build.xml
<project name="Sample usage of Salesforce Ant tasks" xmlns:sfApi="antlib:com.github.mideo.salesforce">
<taskdef resource="com/github/mideo/salesforce/antlib.xml"  
             uri="antlib:com.github.mideo.salesforce" 
             classpath="lib/salesforce-api-client-0.0.1-SNAPSHOT.jar"/>
<!-- persistSObjectToCSV data to csv files   -->
<target name="persistSObjectToCSV" description="Retrieve Custom Settings to SFDC">
       <sfApi:persistSObjectToCSV 
        configFileName="conf.json"
        csvFilesRelativePath="config/customSettings"
        userName="${sf.username}" 
        password="${sf.password}" 
        serverUrl="${sf.serverurl}" 
        />
</target>

 
Publishing/Dataload csv files from directory to sObject

In build.xml
<taskdef resource="com/github/mideo/salesforce/antlib.xml"  
         uri="antlib:com.github.mideo.salesforce" 
         classpath="lib/salesforce-api-client-0.0.1-SNAPSHOT.jar"/> 
    
    <!-- publishCSV data to sfdc   -->
<target name="publishCSV" description="Publish Custom Settings to SFDC">
       <sfApi:publishCSV 
        csvFilesRelativePath="config/settings"
        userName="${sf.username}" 
        password="${sf.password}" 
        serverUrl="${sf.serverurl}" 
       />
</target>

Versions

Version
0.0.4
0.0.3
0.0.2
0.0.1