Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Salesforce client
https://github.com/mideo/salesforce-api-client

ant groovy jar salesforce salesforce-metadata salesforce-rest-api salesforce-soap-api

Last synced: 1 day ago
JSON representation

Salesforce client

Awesome Lists containing this project

README

        

# salesforce-api-client

[![Build Status](https://travis-ci.org/MideO/salesforce-api-client.svg?branch=master)](https://travis-ci.org/MideO/salesforce-api-client)

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.mideo/salesforce-api-client/badge.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.github.mideo%22%20a%3A%22salesforce-api-client%22)

### Setup dependency

JDK "1.8"

#### In build.gradle

##### Add maven url
```groovy
repositories {
mavenCentral()
}

```

##### Add dependency
```groovy
dependencies {
compile group: 'com.github.mideo', name:'salesforce-api-client', version: '0.0.2'
}
```

##### Usage
```Java
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 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 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> 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 filter = new HashMap<>();
filter.put("Product__c","DummyBox");
filter.put("Delivered",true);
List> dataList = webClient.exportDataFromTable("Order__c", filter);

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

```

## Ant Tasks
```Java

Retrieving sObjects to csv
Define config json {: []}

e.g. conf.json
{
"Settings__c" : ["Name","Value__c"],
"Account": ["Name","Email"]
}
In build.xml


Publishing/Dataload csv files from directory to sObject

In build.xml


```