3.0.1-eyegene-3 • Published 3 years ago

clinical6 v3.0.1-eyegene-3

Weekly downloads
655
License
SEE LICENSE IN LI...
Repository
github
Last release
3 years ago

Clinical6-SDK-JS

Build Status Documentation Status

API Internal Documentation

The Clinical6 SDK is a JavaScript library used to access the Clinical6 API.


Configuration

This is a client library that depends on already having a working Clinical6 endpoint. You can quickly verify your endpoint using the following command:

curl -H "Content-Type: application/json" -X POST -d '{"device":{"udid":"sampleid","technology":"ios","push_id":"abc","app_version":"1.0"}}' https://mysite.captivereach.com/api/mobile_users/sign_in_guest

The curl command above should return an alphanumeric auth_token in its response.

Getting Started

Installation

To install for a mobile or web application use the following

npm install clinical6 --save

Contribution

# Pre-project setup: Verify NPM 3.3.12 installed & clone the source code
npm --version
git clone https://github.com/parallel-6/Clinical6-SDK-JS.git

# Install dev dependencies
cd Clinical6-SDK-JS
npm install

Module Loading

This SDK can be used in the browser via a global variable.

<script src="dist/clinical6.js"></script>
<script>
  const clinical6 = new C6.Clinical6();

  clinical6.config.mobileApplicationKey = '123123123211';
  clinical6.device.technology = 'web';
  clinical6.device.udid = '192.0.0.1';
  clinical6.device.appVersion = '0.1';

  clinical6.config = {
    apiBaseUrl: 'https://dhsadobe.captivereach.com',
    track: { flows: false, gps: false }
  };

  clinical6.signIn(); // will automatically use {guest: true} and device
</script>

This is also to be used with ES6 or TypeScript supported technologies (ionic 2)

import { Component, ViewChild } from '@angular/core';
import { Platform, MenuController, Nav } from 'ionic-angular';
import { StatusBar, Splashscreen } from 'ionic-native';
import { HelloIonicPage } from '../pages/hello-ionic/hello-ionic';
import { ListPage } from '../pages/list/list';
import { AppVersion, Device } from 'ionic-native';
import { clinical6, Flow } from 'clinical6';


@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  @ViewChild(Nav) nav: Nav;

  // make HelloIonicPage the root (or first) page
  rootPage: any = HelloIonicPage;
  pages: Array<{title: string, component: any}>;

  constructor(
    public platform: Platform,
    public menu: MenuController
  ) {
    this.initializeApp();

    // set our app's pages
    this.pages = [
      { title: 'Hello Ionic', component: HelloIonicPage },
      { title: 'My First List', component: ListPage }
    ];
  }

  initializeApp() {
    this.platform.ready().then(() => {
      const f: Flow = new Flow();
      clinical6.config.mobileApplicationKey = '123123123211';
      clinical6.apiBaseUrl = 'https://ppdpassport.clinicalreach.com/';
      clinical6.device.udid = Device.uuid;
      clinical6.device.technology = Device.platform;

      AppVersion.getVersionNumber()
        .then(s => (clinical6.device.appVersion = s))
        .then(() => clinical6.signIn())
        .catch(reason => console.log(reason));


      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();
      Splashscreen.hide();
    });
  }

  openPage(page) {
    // close the menu when clicking a link from the menu
    this.menu.close();
    // navigate to the new page if it is not the current page
    this.nav.setRoot(page.component);
  }
}

Initialization

After loading Clinical6 in an HTML file, a new class of Clinical6 instance can be instantiated in JavaScript. You will need to pass in a Clinical6 instance url. If no url is passed, the default url to set will be localhost.

All services as well as a base Clinical6 class have instantiated objects that are camel case. In this example we use the clinical6 object.

import { clinical6 } from 'clinical6';

clinical6.apiBaseUrl = 'https://mysite.captivereach.com';

The clinical6 object has a device and config getter and setter to allow for various settings.

import { clinical6 } from 'clinical6';
clinical6.device.pushId = '28104321'; // default 'FAKE_ID'
clinical6.device.technology = 'ios'; // default null, must be 'android', 'ios', or 'web'
clinical6.device.udid = '2840-1afj03-afjsdf-238fj'; // default null
clinical6.device.appVersion = '0.0.1'; // default null

clinical6.config = {
  apiBaseUrl: 'https://mysite.captivereach.com',  // default undefined
  authToken: '2384af0j238fdjwe0', // default undefined
  track: {
    flows: true, // default true, this will automatically call postInsights on a flow 'go' and 'collect'
    gps: false // default false, this will automatically use gps when postInsights is called
  }
};

In addition, there are direct setters and getters for some of these options for config.

import { clinical6 } from 'clinical6';

clinical6.apiBaseUrl = 'https://mysite.captivereach.com';
clinical6.authToken = '2384af0j238fdjwe0';

CORS

When using the SDK in a Cordova app, CORS is not an issue because the app essentially runs on a file:/// URI. The app controls access through domain whitelisting.

However, when developing against this SDK not in an app, CORS errors often prevents the SDK from working. To bypass CORS errors, do one of the following:

  1. Update the Clinical6 endpoint to allow your endpoint access (Best solution, may not always be possible)
  2. Access the Clinical6 endpoint through a proxy that injects CORS headers (2nd best solution, always possible)
  3. Disable CORS in Chrome (Quickest solution, but NOT recommended as long term development plan. Opens up browser to many vulnerabilities)

Top

NPM Scripts

This repository contains several helpful npm requests that ensures good code quality, runs tests, compiles ECMA6 code to ECMA5, and generates JSDOC documentation from the source code.

The following scripts are available to use for this respository just by navigating to the local installment of this repository and typing in the following in the command-line.

ScriptDescription
npm run buildRuns task sequence clean, compile, webpack, lint, and then test
npm run compileConverts the ECMA6 js files in src and test folders code and puts them in src.babel and test.babel directories
npm run cleanDeletes generates js files in test.babel and src.babel folders.
npm run docCompiles all the comments in the source code and creates html files that define all Classes, methods, parameters, and description in a user-friendly format.
npm installRuns task sequence clean, compile, webpack, lint, and then test
npm run lintChecks the source code for code style consistency using ESLINT configurations.
npm testRuns all the unit tests in the test.babel folder
npm run webpackCombines the src.babel js files into clinical6.js that can run on the browser or node environments each class available.

Requirements

Before you start coding, you'll need to set up your development environment:

SoftwareVersionInstructionsPurpose
NodeJS5.5.0Go to nodejs.org, download Node, and install with default settings using your machine's default installerJavaScript engine
NPM3.3.12Node Package Manager (NPM) is included in the default installation of NodePackage manager
Any JS IDE--Choose an IDE that supports JavaScript coding (e.g. Webstorm v11.0.3+ or Sublime Text 3)JavaScript IDE
Git^2.5.0Download, install, and verify "git" is an executable command from your terminalVersion Control

Top


3.0.1-eyegene-3

3 years ago

3.0.1-eyegene-2

3 years ago

3.19.3

3 years ago

3.19.2

3 years ago

3.19.1

3 years ago

3.19.0

3 years ago

3.16.5

3 years ago

3.18.0

3 years ago

3.16.3

3 years ago

3.16.4

3 years ago

3.17.0

3 years ago

3.16.2

3 years ago

3.16.1

3 years ago

3.16.0

3 years ago

3.9.16-mvp

3 years ago

3.9.14-mvp

3 years ago

3.15.1

4 years ago

3.15.0

4 years ago

3.14.0

4 years ago

3.9.13-mvp

4 years ago

3.13.1

4 years ago

3.13.0

4 years ago

3.12.12

4 years ago

3.12.11

4 years ago

3.12.10

4 years ago

3.12.9

4 years ago

3.12.8

4 years ago

3.12.7

4 years ago

3.12.6

4 years ago

3.12.5

4 years ago

3.12.4

4 years ago

3.12.3

4 years ago

3.12.2

5 years ago

3.12.1

5 years ago

3.12.0

5 years ago

3.11.3

5 years ago

3.11.2

5 years ago

3.11.1

5 years ago

3.11.0

5 years ago

3.10.1

5 years ago

3.10.0

5 years ago

3.0.3-2

5 years ago

3.0.3-1

5 years ago

3.9.14

5 years ago

3.9.13

5 years ago

3.9.12

5 years ago

3.9.11

5 years ago

3.9.10

5 years ago

3.9.9

6 years ago

3.9.8

6 years ago

3.9.7

6 years ago

3.9.6

6 years ago

3.9.5

6 years ago

3.9.4

6 years ago

3.9.3

6 years ago

3.9.2

6 years ago

3.9.0

6 years ago

3.8.7

6 years ago

3.8.6

6 years ago

3.8.5

6 years ago

3.8.4

6 years ago

3.8.3

6 years ago

3.8.2

6 years ago

3.8.1

6 years ago

3.8.0

6 years ago

3.7.2

6 years ago

3.7.1

6 years ago

3.7.0

6 years ago

3.6.3

6 years ago

3.6.2

6 years ago

3.6.1

6 years ago

3.6.0

6 years ago

3.5.3

6 years ago

3.5.2

6 years ago

3.5.1

6 years ago

3.5.0

6 years ago

3.4.1

6 years ago

3.4.0

6 years ago

3.3.0

6 years ago

3.2.3

6 years ago

3.2.2

6 years ago

3.2.1

6 years ago

3.2.0

6 years ago

3.1.1

6 years ago

3.1.0

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.13.5

6 years ago

2.13.3

6 years ago

2.13.2

6 years ago

2.13.1

6 years ago

2.13.0

6 years ago

2.12.0

6 years ago

2.11.0

6 years ago

2.10.8

6 years ago

2.10.7

6 years ago

2.10.6

6 years ago

2.10.5-1

6 years ago

2.10.5

6 years ago

2.10.4-0

6 years ago

2.10.4

6 years ago

2.10.3

6 years ago

2.10.2

6 years ago

2.10.1

6 years ago

2.10.0

6 years ago

2.9.7

6 years ago

2.9.6

6 years ago

2.9.5

6 years ago

2.9.4

6 years ago

2.9.3

6 years ago

2.9.2

6 years ago

2.9.1

6 years ago

2.9.0

6 years ago

2.8.4

6 years ago

2.8.3

6 years ago

2.8.2

6 years ago

2.8.1

6 years ago

2.7.2

6 years ago

2.5.16-0

7 years ago

2.7.1

7 years ago

2.6.9

7 years ago

2.6.8

7 years ago

2.6.7

7 years ago

2.6.6

7 years ago

2.6.5

7 years ago

2.6.4

7 years ago

2.6.3

7 years ago

2.6.2

7 years ago

2.6.1

7 years ago

2.6.0

7 years ago

2.5.17

7 years ago

2.5.16

7 years ago

2.5.15

7 years ago

2.5.14

7 years ago

2.5.13

7 years ago

2.5.12

7 years ago

2.5.11

7 years ago

2.5.10

7 years ago

2.5.9

7 years ago

2.5.8

7 years ago

2.5.7

7 years ago

2.5.6

7 years ago

2.5.5

7 years ago

2.5.4

7 years ago

2.5.3

7 years ago

2.5.2

7 years ago

2.5.1

7 years ago

2.5.0

7 years ago

2.4.8

7 years ago

2.4.7

7 years ago

2.4.6

7 years ago

2.4.5

7 years ago

2.4.4

7 years ago

2.4.3

7 years ago

2.4.2

7 years ago

2.4.1

7 years ago

2.4.0

7 years ago

2.3.8

7 years ago

2.3.7

7 years ago

2.3.6

7 years ago

2.3.5

7 years ago

2.3.4

7 years ago

2.3.3

7 years ago

2.3.2

7 years ago

2.3.1

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.1.29

7 years ago

2.1.28

7 years ago

2.1.27

7 years ago

2.1.26

7 years ago

2.1.25

7 years ago

2.1.24

7 years ago

2.1.23

7 years ago

2.1.22

7 years ago

2.1.21

7 years ago

2.1.20

7 years ago

2.1.19

7 years ago

2.1.18

7 years ago

2.1.17

7 years ago

2.1.16

7 years ago

2.1.15

7 years ago

2.1.14

7 years ago

2.1.13

7 years ago

2.1.12

7 years ago

2.1.11

7 years ago

2.1.10

7 years ago

2.1.9

7 years ago

2.1.8

7 years ago

2.1.7

7 years ago

2.1.6

7 years ago

2.1.5

7 years ago

2.1.4

7 years ago

2.1.3

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.7.8

7 years ago

1.7.7

7 years ago

1.7.6

7 years ago

1.7.5

7 years ago

1.7.4

7 years ago

1.7.3

7 years ago

1.7.2

7 years ago

1.7.1

7 years ago

1.7.0

7 years ago

1.6.3

7 years ago

1.6.2

7 years ago

1.6.1

7 years ago

1.6.0

7 years ago

1.5.1

7 years ago

1.4.0

7 years ago

1.3.4

7 years ago

1.3.3

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago