Giter Club home page Giter Club logo

capsulecrm-java's Introduction

capsulecrm-java Build Status

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, 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

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.

capsulecrm-java's People

Contributors

analytically avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

capsulecrm-java's Issues

Fix UTF-8 support

There are issues with sending UTF-8 encoded data. XStream is the culprit.

Missing tagId field on CustomFieldDefinition

The CCustomFieldDefinition is missing the tagId property.

When fetching custom field definitions with the library I get the error:

java.util.concurrent.ExecutionException: com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$UnknownFieldException: No such field uk.co.coen.capsulecrm.client.CCustomFieldDefinition.tagId
---- Debugging information ----
message             : No such field uk.co.coen.capsulecrm.client.CCustomFieldDefinition.tagId
field               : tagId
class               : uk.co.coen.capsulecrm.client.CCustomFieldDefinition
required-type       : uk.co.coen.capsulecrm.client.CCustomFieldDefinition
converter-type      : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
path                : /customFieldDefinitions/customFieldDefinition/tagId
line number         : 1
class[1]            : uk.co.coen.capsulecrm.client.CCustomFieldDefinitions
version             : 1.4.9
-------------------------------

Not all custom field definitions have the tagId property, but some do. Here is a sample:

 "customFieldDefinition": [
      {
        "id": "12345678",
        "tag": "TagName",
        "tagId": "98765",
        "label": "A label",
        "type": "Boolean",
        "displayOrder": "1",
        "forPartyClass": "ORGANISATION"
      },

Plans to support API v2?

Many thanks for this library. It's been working great for us for some years now.

Do you have any pans to upgrade the library to support API v2?

Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.