0.9.0 • Published 5 years ago

lahdes-api v0.9.0

Weekly downloads
1
License
BSD
Repository
github
Last release
5 years ago

Lahdes NodeJs API package

Simplifies calls and communication with Lahdes API, thus providing an even easier way for the businesses to integrate Lahdes service in their existing framework.

Basic usage

Initialise the library with appropriate values

    var Lahdes = require('Lahdes');

    // ...

    api = Lahdes({
      clientId: 'client_id_provided_by_lahdes',
      clientSecret: 'client_secret_provided_by_lahdes',
      environment: 'production',
    });
VariableRequiredTypeDescription
clientIdYesStringIdentification provided by Lahdes
clientSecretYesStringIdentification provided by Lahdes
environmentNoStringDefaults to production if not set explicitly

Request public key for the user

Only thing necessary to initiate file delivery is recipients Personal Identification Number.

    await api.requestPublicKey(serialNumber);
VariableRequiredTypeDescription
serialNumberYesStringUser personal identification number in format PNOLV-000000-00000

Encrypt and send the file to the recipient

Relative path to the file must be provided, encryption is applied before the file is sent to the Lahdes. For additional assurance of recipient aknowledgment, phone number must be provided to which the notification will be sent, unless Lahdes database has more up-to-date contact information of the user.

    await api.sendAndEncryptFile(file, fileName, options = {});
VariableRequiredTypeDescription
fileYesStringPath to the file which should be encrypted and sent
fileNameYesStringDesired filename to be used for the recipient
optionsNoObjectList of options to customise the Request

Possible options which can be passed with request

VariableRequiredTypeDescription
phoneNumberNoStringPhone number in international format, ex. +37100000000, defaults to phone number provided by recipient (if any)
sendTextNoBooleanMust be passed as true to perform the text message delivery, defaults to false