capsulecrm-java
NOTE: this client library implements version 1 of the Capsule API. Deprecation warning - version 1 of the Capsule API will not be available after October 27, 2017.
Unofficial Capsule CRM API Java Client.
Depends on Async Http Client, Google Guava, XStream and Joda-Time. Development sponsored by Coen Education. Follow @analytically for updates.
Requirements
Java 8 or later. A Capsule CRM account and token.
Using with Maven
Add this dependency to your project's POM file:
<dependency>
<groupId>uk.co.coen</groupId>
<artifactId>capsulecrm-java</artifactId>
<version>1.3.4</version>
</dependency>
Using with SBT
Add this dependency to your project's build.sbt
or project/Build.scala
file:
libraryDependencies += "uk.co.coen" % "capsulecrm-java" % "1.3.4"
Configuration
Add an application.conf
property file to your application's classpath with the Capsule CRM url and token. Capsule CRM users can find their API token by visiting My Preferences
via their username menu in the Capsule navigation bar.
capsulecrm.url="https://<yourdomain>.capsulecrm.com"
capsulecrm.token="<your token here>"
Google Custom Search Engine for your Capsule CRM contact's websites
If you need a Google Custom Search searching all websites of your contacts, see the gcse
directory for a Play Framework application hosting custom search annotations files. Point Google Custom Search to a server hosting this application.
- In
gcse/conf/application.conf
, changecapsulecrm.url
andcapsulecrm.token
to your Capsule CRM account details - In
gcse/conf/application.conf
, changegcs.label
to your Custom Search Engine label. - Run the application by using the
play run
command, see here for more information. - Under
Control panel > Advanced > Add annotations feed
, addhttp://yourhost/cse/persons
for all person annotations, orhttp://yourhost/cse/organisations
for all organisation annotations.
See Hosting the Annotation Files Yourself for more details.
Usage
Start by importing the client package and the necessary classes:
import java.util.concurrent.Future;
import uk.co.coen.capsulecrm.client.*
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import static com.google.common.util.concurrent.JdkFutureAdapters.listenInPoolThread;
Fetch all parties, change something and save - asynchronous:
Futures.addCallback(listenInPoolThread(CParty.listAll()), new FutureCallback<CParties>() {
@Override
public void onSuccess(CParties parties) {
for (CParty party : parties) {
party.about = "...";
if (party instanceof COrganisation) {
COrganisation org = (COrganisation) party;
// if it's an organisation, change it's name
org.name = "...";
}
// save changes - blocking
Response response = party.save().get();
if (response.getStatusCode() < 200 || response.getStatusCode() > 206) {
log.info("Failure saving party " + party + ", response " + response.getStatusCode() + " " + response.getStatusText());
}
}
}
});
Add a tag to a party:
party.add(new CTag("iamatag"));
Add a note to a party:
party.add(new CHistoryItem("hello I'm a note"));
Add a task to a party:
party.add(new CTask("do this in two days", DateTime.now().plus(2)));
Click here for more examples.
Javadoc
http://www.javadoc.io/doc/uk.co.coen/capsulecrm-java
License
Licensed under the Apache License, Version 2.0.
Copyright 2011-2016 Mathias Bogaert.