npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

divera247-api-unofficial

v0.2.16

Published

Unofficial Divera 24/7 API Wrapper

Downloads

71

Readme

Divera 24/7 API Wrapper

An unofficial Node package to interface with Divera 24/7 by wrapping the mess the API is into a usable library. This project is not in any way affiliated with divera247.com / DIVERA GmbH. Official Divera API Documentation can be found here: https://api.divera247.com/

Quality Gate Status

Current features finished and planned

Below are all the request types the package supports currently (ticked) and the ones that are currently not implemented but planned to be. Contributions are welcome!

  • [ ] Alarm
    • [x] Create Alarm
    • [x] Read all Alarms
    • [x] Read Alarm
    • [x] Delete Alarm
    • [x] Close Alarm
    • [ ] Alarm User Responses
    • [x] Archive Alarm
  • [ ] Pull all
    • [x] Read Groups
    • [x] Read specific value by key
    • [x] Read all vehicles
  • [ ] Messages
    • [ ] Write Messages
    • [ ] Read Messages
  • [ ] Vehicle
    • [x] Set status
    • [x] Get status

Getting Started

These instructions will show you how to use this package in your project. If you want to contribute, check Contributing.

Prerequisites

If you, for whatever reason, want to use this package fronted wise, it is possible since axios supports browsers. We also export CJS and ESM.

Installing

npm i divera247-api-unofficial

Usage

this is currently in the making! After installing the package you can use it as shown below.

Authorize

Retrieve the access token with user credentials (e.g. with a system user).

import {DiveraClient} from 'divera247-api-unofficial';
// CJS: const {DiveraClient} = require('divera247-api-unofficial');
try {
    const token = await DiveraClient.getAccessToken('username', 'password');
} catch (e) {
    // failed to retreive token
}

Declare the client

import {DiveraClient} from 'divera247-api-unofficial';
// CJS: const {DiveraClient} = require('divera247-api-unofficial');

const diveraClient = new DiveraClient(token);

Pull All (/v2/pull/all)

The pull all endpoint pretty much delivers everything there is for a tenant. This package includes some helpers to extract the data you need.

Read specific data Provide the path of the specific property you want to extract from the /pull/all response.

const {data: {user}} = await diveraClient.getAllByPath<{
  firstname: string;
  lastname: string;
}>('cluster', 'user');

Groups

import {
  DiveraResponse
} from "./divera-response.model";

const groups: DiveraResponse<Group[]> = await diveraClient.getGroups();

// Get Groups sorted by Divera provided `groupsorting`
const sortedGroups = await diveraClient.getGroups(true);

Alarm (/v2/alarms)

Create Alarm

The CreateAlarm model represents the payload to the Divera API. Alarm for the alarm details, Instructions to tell if the groups, vehicles etc are passed as id or name.

const alarm: CreateAlarm = {
    Alarm: {
        title: "This is an alarm!!!",
        group: [1234],
        ...
    },
    Instructions: {
        group: "id",
        ...
    }
}

A more convenient way is to use the builder:

const alarm = new AlarmBuilder()
  // set address of the scene
  .address('Foostreet 1337')
  // set coordinates (lat, lng) of the scene
  .coordinates(50.321, 10.123)
  // set units mapped by their ids
  .groups([1, 2, 3], 'id')
  .vehicles([1, 2, 3], 'id')
  // set a title, text and a type
  .details('title', 'description')
  // set prioity flag to true
  .isPriority()
  // send as push alarm
  .sendPush()
  // set foreign operation id (e.g. from external software)
  .foreignId('external id 123')
  // ...
  .build();

Retrieve alarms

const alarms = await diveraClient.getAlarms();
const alarm = await diveraClient.getAlarm("alarm id");

Create, Close, Archive and Delete an Alarm

// Create an alarm
const resp = await diveraClient.createAlarm(alarm);
// Close an alarm with an optional report
await diveraClient.closeAlarm(resp.data.id, 'some report');
// Archive an alarm
await diveraClient.archiveAlarm(resp.data.id);
// Delete the alarm
await diveraClient.deleteAlarm(resp.data.id);

Vehicles (/v2/using-vehicles)

Set Vehicle Status

const vehicleId = 1;
const vehicleStatus = 3;
const optionalPosition = {
  lat: 53.551086,
  lng: 9.993682,
};
await diveraClient.setVehicleStatus(
  vehicleId,
  vehicleStatus,
  'optional status note',
  optionalPosition,
);

Error handling

The package is non throwing for requests (except for getAccessToken). Every error will be represented as a DiveraResponse. The success is indicated with the success property. An error response is equivalent to the response from Divera. If the errors origin is the package, the error property will contain the error message.

Contributing

If you have a feature request, or you caught an error please create an issue.

If you want to create a new endpoint create a new folder under ./src/endpoints with the name of the root path of the endpoint and extend the BaseClient. Register the Endpoint Class in the index.ts file.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Shameless Plug

We are using the package over at Kordis, an open-source software for rescue operations control centres. Come check it out and contribute if you like! Also, if you are looking for Geospatial Tools such as Geocoding, Address Autocompletion and general Location Intelligence check out Cartesius.