= Introduction =

This package contains sample code to demonstrate usage of the CounselLink Integration APIs.

== Requirements ==

=== API key pair ===

An API key pair - this would be a combination of access_key and secret_key.

The secret_key is a shared secret and on CounselLink's end is encrypted and saved.
API clients needs to store the secret_key in a safe location as well. A encypted version in a key store is a good solution.

The Java runtime tries to find these properties using a library called Archaius (https://github.com/Netflix/archaius).

Archaius looks for a configuration file names "config.properties". The keys can also be specified via -D command line params.

An example config.properties is located in src/main/resources. The keys are:

  cl.int.api.rest.accessKey=ACCESS
  cl.int.api.rest.secretKey=SECRET

To use the sample please update the above two keys. The sample code expects the keys to be supplied via the properties file or via command line parameters.
The API client developer can make changes as needed to fetch the keys from other alternatives.

=== CounselLink Integration URL endpoint ===

The endpoint to invoke will be provided by CounselLink business consultant. For the samples these need to be provided in the application.properties file.

  cl.int.api.rest.endpoint=CHANGE_ME

The above can be provided via command line as well via -D parameters to the JVM.

== Build ==

The project can be built with maven. The zip file that had this README file also has a lib folder with an "uber" jar of all dependencies.

CounselLink Integration API jars are included in the uber jar (lib/client-examples-6.1.0-SNAPSHOT.jar). The "common" and "client" jar are of importance.

  cd lib
  jar -xvf client-examples-6.1.0-SNAPSHOT.jar
  cd lib
  ls common-6.1.0-SNAPSHOT.jar
  ls rest-client-6.1.0-SNAPSHOT.jar

The above jars need to be included in the classpath. With maven they can be included as:

        <dependency>
            <groupId>com.lxnx.edi</groupId>
            <artifactId>rest-client</artifactId>
            <version>6.1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.lxnx.edi</groupId>
            <artifactId>common</artifactId>
            <version>6.1.0-SNAPSHOT</version>
        </dependency>

They can be installed into the local maven repository.

  mvn install:install-file -Dfile=common-6.1.0-SNAPSHOT.jar -DgroupId=com.lxnx.edi -DartifactId=common -Dversion=6.1.0-SNAPSHOT -Dpackaging=jar
  mvn install:install-file -Dfile=rest-client-6.1.0-SNAPSHOT.jar -DgroupId=com.lxnx.edi -DartifactId=rest-client -Dversion=6.1.0-SNAPSHOT -Dpackaging=jar

Once the jars are installed, maven can build the project
  mvn clean package

== Run ==

The build would generate the binary in the target folder and this can be invoked as:
  java -jar client-examples-6.1.0-SNAPSHOT.jar

== Proxy support ==
Client API users can create their own instance of OkHttpClient for proxy configurations, and instantiate the appropriate client as need be.

        OkHttpClient okHttpClient = new OkHttpClient()
        Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));
        okHttpClient.setProxy(proxy);
        MatterClient.Builder matterBuilder = new MatterClient.Builder();
        matterBuilder.setOkHttpClient(okHttpClient);
        MatterClient matterClient = matterBuilder.build();
