Class: EvamApi

EvamApi.EvamApi

Evam API singleton that exposes methods to interact with the Evam platform.

Example

// Get instance (don't be afraid to copy them around or create more, as they're simply a lightweight reference to shared static data)
const evamApi = new EvamApi();

// Register a new callback on any operation update that simply logs it
evamApi.onNewOrUpdatedActiveOperation((activeOperation) => console.log(activeOperation));

// Register a new callback on any application settings update that simply logs them
evamApi.onNewOrUpdatedSettings((settings) => console.log(settings));

//Register a new callback to any specific application data update. Available register methods:
evamApi.onNewOrUpdatedDeviceRole((deviceRole) => ...);
evamApi.onNewOrUpdatedLocation((location) => ...);
evamApi.onNewOrUpdatedInternetState((internetState) => ...);
evamApi.onNewOrUpdatedVehicleState((vehicleState) => ...);
evamApi.onNewOrUpdatedTripLocationHistory((tripLocationHistory) => ...);

// Send a new notification to VS (this will also work for the developer environment)
// This will display a notification with heading "example", description "lorem ipsum". It will have type 'QUICK_HUN' and a primary button
// which is labelled 'primary button' that doesn't do anything when called. The secondary button is not defined, thus it will not display.
evamApi.sendNotification(new Notification("example","lorem ipsum", NotificationType.QUICK_HUN, {label:'primary button', callback:()=>{}}, undefined))

//Remove all callbacks from the SDK (this is useful for cleanup)
evamApi.unsubscribeFromAllCallbacks()

//Detect whether the certified app is currently running in Vehicle Services
EvamApi.isRunningInVehicleServices

//update the current hospital by id (be sure that the hospital is listed in available hospitals)
evamApi.setHospital(1234)

//update the current priority (be sure that the priority is listed in available priorities)
evamApi.setPriority (1)

//simulate Vehicle Services data inject (development + testing only)
//DO NOT USE THESE METHODS IN PRODUCTION, While not breaking by any means they will not perform any function.
evamApi.injectLocation(new Location(59.364, 18.012, new Date()))
evamApi.injectVehicleState(new VehicleState(...))
evamApi.injectTrip(new TripLocationHistory(...))
evamApi.injectDeviceRole(new DeviceRole(...))
evamApi.injectInternetState(new InternetState(...))
evamApi.injectOperation(new Operation(...))
evamApi.injectSettings(new Settings(...))
evamApi.injectOperationList([new Operation(...), new Operation(...), ...])
evamApi.injectBattery(new Battery(...)))

Constructors

constructor

new EvamApi()

Properties

isRunningInVehicleServices

Static Readonly isRunningInVehicleServices: boolean

True if Vehicle Services environment is detected, False otherwise (for instance a web application) We have to ignore this because the Android item causes an error.

Methods

getAppVersion

getAppVersion(): string

Returns

string


getDeviceId

getDeviceId(): string

Returns

string


getGRPC

getGRPC(): GRPC

Returns

GRPC


getOSVersion

getOSVersion(): string

Returns

string


getVehicleServicesVersion

getVehicleServicesVersion(): string

Returns

string


injectAppVersion

injectAppVersion(appVersion): void

Parameters

Name

Type

appVersion

string

Returns

void


injectBattery

injectBattery(battery): void

Injects the battery manually. This will trigger onNewOrUpdatedBattery(…)’s callback. This function is to be used for development only and will throw an error when used in Vehicle Services.

Parameters

Name

Type

Description

battery

Battery

The battery to be injected for development purposes.

Returns

void


injectDeviceRole

injectDeviceRole(deviceRole): void

Manually inject deviceRole to EvamApi (Only available in development.)

Parameters

Name

Type

Description

deviceRole

DeviceRole

the deviceRole to inject.

Returns

void


injectDisplayMode

injectDisplayMode(displayMode): void

Injects the display mode manually. This will trigger onNewOrUpdatedDisplayMode(…)’s callback. This function is to be used for development only and will throw an error when used in Vehicle Services.

Parameters

Name

Type

Description

displayMode

DisplayMode

The display mode (light or dark) to be injected for development purposes.

Returns

void


injectInternetState

injectInternetState(internetState): void

Manually inject internetState to EvamApi (Only available in development.)

Parameters

Name

Type

Description

internetState

InternetState

the internetState to inject.

Returns

void


injectLocation

injectLocation(location): void

Manually inject location to EvamApi (Only available in development.)

Parameters

Name

Type

Description

location

Location

the location to inject.

Returns

void


injectOSVersion

injectOSVersion(osVersion): void

Parameters

Name

Type

osVersion

string

Returns

void


injectOperation

injectOperation(activeCase): void

Injects the Active Operation manually. This will trigger onNewOrUpdatedActiveOperation(…)’s callback. This function is to be used for development only and will throw an error when used in Vehicle Services.

Parameters

Name

Type

Description

activeCase

Operation

The active case to be injected for development purposes.

Returns

void


injectOperationList

injectOperationList(operationList): void

Injects the operation list manually. This will trigger onNewOrUpdatedOperationList(…)’s callback. This function is to be used for development only and will throw an error when used in Vehicle Services.

Parameters

Name

Type

Description

operationList

Operation[]

The operation list to be injected for development purposes.

Returns

void


injectSettings

injectSettings(settings): void

Injects the settings manually. This will trigger onNewOrUpdatedSettings(…)’s callback. This function is to be used for development only and will throw an error when used in Vehicle Services.

Parameters

Name

Type

Description

settings

any

The settings to be injected for development purposes.

Returns

void


injectTrip

injectTrip(tripLocationHistory): void

Manually inject tripLocationHistory to EvamApi (Only available in development.)

Parameters

Name

Type

Description

tripLocationHistory

TripLocationHistory

the tripLocationHistory to inject.

Returns

void


injectVSVersion

injectVSVersion(vsVersion): void

Parameters

Name

Type

vsVersion

string

Returns

void


injectVehicleState

injectVehicleState(vehicleState): void

Manually inject vehicleState to EvamApi (Only available in development.)

Parameters

Name

Type

Description

vehicleState

VehicleState

the vehicleState to inject.

Returns

void


onNewOrUpdatedActiveOperation

onNewOrUpdatedActiveOperation(callback): void

Registers a callback to be run upon a new Active Operation is available or the current Active Operation is updated.

Parameters

Name

Type

Description

callback

CallbackFunction<Operation, void>

The callback to be executed

Returns

void


onNewOrUpdatedBattery

onNewOrUpdatedBattery(callback): void

Used to assign a callback when the battery created or updated.

Parameters

Name

Type

Description

callback

CallbackFunction<Battery, void>

The callback with (optional) argument battery. Use this to access the battery.

Returns

void


onNewOrUpdatedDeviceRole

onNewOrUpdatedDeviceRole(callback): void

Registers a callback to be run upon new device role or device role update

Parameters

Name

Type

Description

callback

CallbackFunction<DeviceRole, void>

The callback to be executed.

Returns

void


onNewOrUpdatedDisplayMode

onNewOrUpdatedDisplayMode(callback): void

Used to assign a callback when the display mode is created or updated.

Parameters

Name

Type

Description

callback

CallbackFunction<DisplayMode, void>

The callback with (optional) argument displayMode. Use this to access the display mode.

Returns

void


onNewOrUpdatedInternetState

onNewOrUpdatedInternetState(callback): void

Registers a callback to be run upon new internetState or internetState update

Parameters

Name

Type

Description

callback

CallbackFunction<InternetState, void>

The callback to be executed.

Returns

void


onNewOrUpdatedLocation

onNewOrUpdatedLocation(callback): void

Registers a callback to be run upon new location or location update

Parameters

Name

Type

Description

callback

CallbackFunction<Location, void>

The callback to be executed.

Returns

void


onNewOrUpdatedOperationList

onNewOrUpdatedOperationList(callback): void

Used to assign a callback when the operation list is created or updated.

Parameters

Name

Type

Description

callback

CallbackFunction<Operation[], void>

The callback with (optional) argument operationList. Use this to access the operation list.

Returns

void


onNewOrUpdatedSettings

onNewOrUpdatedSettings(callback): void

Registers a callback to be run upon new application settings reception or settings update

Parameters

Name

Type

Description

callback

CallbackFunction<any, void>

The callback to be executed.

Returns

void


onNewOrUpdatedTripLocationHistory

onNewOrUpdatedTripLocationHistory(callback): void

Used to assign a callback when the trip location history is created or updated.

Parameters

Name

Type

Description

callback

CallbackFunction<TripLocationHistory, void>

The callback with (optional) argument tripLocationHistory. Use this to access the trip location history.

Returns

void


onNewOrUpdatedVehicleState

onNewOrUpdatedVehicleState(callback): void

Used to assign a callback when the vehicle state is created or updated.

Parameters

Name

Type

Description

callback

CallbackFunction<VehicleState, void>

The callback with (optional) argument vehicleState. Use this to access the vehicle state.

Returns

void


sendNotification

sendNotification(notification): void

send a notification to vehicle services (or evam-dev-environment if using the dev environment)

Parameters

Name

Type

notification

Notification

Returns

void


setHospital

setHospital(id): void

Sets the selected hospital id for the current active operation. The id must be present inside the available hospitals

Parameters

Name

Type

Description

id

number

the id of the hospital to be set

Returns

void


setPriority

setPriority(id): void

Sets the selected priority id for the current active operation. The id must be present inside the available priorities.

Parameters

Name

Type

Description

id

number

of the priority to be set

Returns

void


unsubscribeFromAllCallbacks

unsubscribeFromAllCallbacks(): void

Unsubscribes all registered callbacks from Vehicle Service events.

Returns

void