Hypertrack client library

This library helps in fetching and updating HyperTrack entities.

The library is written in typescript but can be used with vanilla javascript

Installation

npm install ht-client

Prerequesit

Install HyperTrack library internally used by ht-client.

npm i ht-data
npm i ht-utility
npm i ht-map

Install other helper libraries

npm i rxjs
npm i underscore
npm i moment-mini
Usage

Library exposes htClient as a global variable when used as es5. Otherwise can be used with es6+. javascript

var TOKEN = "sk_xxxxxxxxxxxxxxxxxxxxxxxxx"
var client = new htClient.HtClient(TOKEN);

typescript

import {HtClient} from "ht-client"

var TOKEN = "sk_xxxxxxxxxxxxxxxxxxxxxxxxx"
var client = new HtClient(TOKEN);

References

HtClient

Class which contains HyperTrack entity clients. Needs to be initialized with HyperTrack token token. javascript

var client = new htClient.HtClient(<HT_TOKEN>);
client.mapClass = mapClass;

typescript

import { HtClient} from 'ht-client';

var client = new HtClient(<HT_TOKEN>);

HtClient.users

Contains users related client functions.

HtClient.users.placeline

Placeline client

Methods
  • setId(userId: string | null): set to null to clear existing placeline
  • setQuery(query: object): example {day: "2017-10-29"}
Methods
  • id$: Observable<string | null | undefined>
  • query$: Observable<object | null | undefined>
  • data$: Observable<IUserData>: Observable that emits latest placeline data of a user every 10 seconds.
  • loading$: Observable<boolean | string>: Can be used to show loading state of the api

HtClient.users.list

User list client

Methods
  • setActive(active: boolean = true): Start fetching data
  • setQuery(query: object): example {day: "2017-10-29"}
Properties
  • query$: Observable<object | null | undefined>
  • data$: Observable<IUserData>: Observable that emits latest users list of a user every 10 seconds.
  • loading$: Observable<boolean | string>: Can be used to show loading state of the api
  • defaultParams: object: Can be used to set default parameters like page_size: number and ordering
  • updateStrategy: 'once' | 'live' | poll': 'once' will fetch data once, 'live' will fetch latest data, 'poll' will fetch a first set of data and updated these fetched users on regular interval. Default is 'poll'

HtClient.users.listAll

Fetches all user data across the pages. Can be used to displaying markers on the map. By default this api emits data once. This can be configured to emit latest value on regular interval using pollDuration and updateStrategy properties.

Methods
  • setActive(active: boolean = true): Start fetching data
  • setQuery(query: object): example {day: "2017-10-29"}
Properties
  • data$: Observable<AllData<IUserData>>: Observable that emits latest all users list of a user every 10 seconds.
  • loading$: Observable<boolean | string>: Can be used to show loading state of the api
  • query$: Observable<object | null | undefined>
  • defaultParams: object: Can be used to set default parameters like page_size: number
  • updateStrategy: 'once' | poll'

HtClient.users.api: HtUsersApi

Contains users specific api calls

Methods
  • get(id: string, query = {}): Observable<IUser>
  • index(query = {}): Observable<Page<IUser>>
  • summary(query = {}): Observable<IUserListSummary>
  • heatmap(query = {}): Observable<IUserPlace>
  • placeline<T>(id, query = {}): Observable<IUserData>
  • analytics(query): Observable<IUserAnalyticsPage>
Example

javascript

var client = new htClient.HtClient(<HT_TOKEN>);
client.users.api.get(<USER_ID>).subscribe(function(user) {
  //user
})

typescript

import { HtClient } from "ht-client"
var client = new HtClient(<HT_TOKEN>);
client.users.api.get(<USER_ID>).subscribe((user: IUser) => {
  //user
})

HtClient.mapClass

Usage

javascript

var client = new htClient.HtClient(<HT_TOKEN>);
var mapClass = new htMaps.HtMapClass('google');
client.mapClass = mapClass //<---- Note this

typescript

import { HtMapClass} from 'ht-maps';
import { HtClient } from "ht-client"

var client = new HtClient(<HT_TOKEN>);
var mapClass = new HtMapClass('google');
client.mapClass = mapClass //<---- Note this

By setting mapClass property to an initialized HtMapClass, the client data will automatically get rendered in the map.

results matching ""

    No results matching ""