Skip to content
This repository has been archived by the owner on Apr 6, 2018. It is now read-only.

Latest commit

 

History

History
122 lines (85 loc) · 4.24 KB

README.md

File metadata and controls

122 lines (85 loc) · 4.24 KB

capsulecrm-java Build Status

Unofficial Capsule CRM API Java Client.

Depends on Async Http Client, Google Guava, XStream and Joda-Time. Development sponsored by Coen Recruitment. 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.2</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.2"

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, change capsulecrm.url and capsulecrm.token to your Capsule CRM account details
  • In gcse/conf/application.conf, change gcs.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, add http://yourhost/cse/persons for all person annotations, or http://yourhost/cse/organisations for all organisation annotations.

See Hosting the Annotation Files Yourself for more details.

Usage Examples

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.

License

Licensed under the Apache License, Version 2.0.

Copyright 2011-2015 Mathias Bogaert.