0.3.0 • Published 8 years ago

calais-js-client v0.3.0

Weekly downloads
1
License
ISC
Repository
-
Last release
8 years ago

CommonJS Calais Client

Implementation

To post data into Calais you will need a Passport ID and a Passport Secret - contact elliot.coad@shortlist.com to request access.

calais-js-client can be included in your project a few different ways:

CommonJS

If you use browserify or webpack then install from npm as calais-js-client

To use in your project require as you would any other package:

First install and save to your project's dependecies npm i -S calais-js-client

Then in your project:

var CalaisClient = require('calais-js-client')

// Instantiate client, you can pass in your payload here
var calaisClient = new CalaisClient(PASSPORT_ID, PASSPORT_SECRET, [optional dataRecord object]

// If you want to post repeatedly, you can use the .setDataRecord api
calaisClient.setDataRecord(dataRecordObject)

// When you're read to send your data, call the .post() method.
// .post() returns a promise

calaisClient.post().then(handleResolvedPromise, handleRejectedPromise)

Hosted Client

You can include a hosted version of the Calais JS Client from our server. It requires no dependencies.

<script src="http://js-client.calaisapi.com/dist/calais-client.min.js"></script>

Build Standalone Client locally

npm run-script bundle will create a standalone calais-client.min.js file in the ./dist folder. You can then include this in your current JavaScript setup.

Dependencies

The client is bundled with SuperAgent, CryptoJS, and es6-promise. So requires no external dependencies.

Browser Support

Calais JS Client supports modern browsers and IE9+

Build & tests

Tests are included in test/test.js

Create a file containing your test passport credentials

cp test/example.test-passport-credentials.json test/test-passport-credentials.json

Run npm install && gulp to build the script and run the tests

Deploying client

Add to SSH config:

[remote "production"]
  url = ssh://trusty/var/application/repos/calais-js-client.git
  fetch = +refs/heads/*:refs/remotes/production/*

Deploy:

git push production master
0.3.0

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago