@alme-es/api-ts
v0.1.4
Published
Typescript Alme Rest API
Downloads
4
Readme
NIT Alme API
This module provides the api layer for interacting with Alme.
Features
- [x] Provides Typescript implementation of Alme API
Installation
Npm
Add this module to the dependencies
section of your package.json
{
"dependencies": {
"@alme-es/api-ts": "^0.0.0"
}
}
Then, run the following command:
npm install
Components
Settings
This module includes a set of default settings it needs to function. These settings may be partially or completely overridden.
List of Default Settings
// Default request settings. See AlmeApiSettings.ts
let apiSettings: IAlmeApiSettings = {
AlmeApiProtocol: 'https://',
AlmeApiHostname: (globalThis && globalThis.location && globalThis.location.hostname) || (window && window.location && window.location.hostname) || 'unknown',
AlmeApiBasePath:'/AlmeAPI/api/',
AlmeApiRequestTimeout: 10000,
AlmeApiConversationRoot: 'Conversation',
AlmeApiConversePath: '/Converse',
AlmeApiAppEventPath: '/AppEvent',
AlmeApiReportingEventPath: 'Conversation/ReportingEvent',
AlmeApiRequestUnitPath: '/RequestUnit',
AlmeApiConverseEndpoint: 'Conversation/Converse',
AlmeApiAppEventEndpoint: 'Conversation/AppEvent',
AlmeApiRequestUnitEndpoint: 'Conversation/RequestUnit',
AlmeApiGetHistoryEndpoint: 'ConversationSupport/GetHistory',
AlmeApiReportingEventEndpoint: 'Conversation/ReportingEvent',
AlmeApiConfigurationEndpoint: 'Configuration/GetConfiguration',
};
Usage
The module exposes a class called AlmeAPI
that accepts a
logger, httpHandler, and apiSettings.
import { AlmeApi } from '@alme-es/api-ts/build/AlmeApi';
import { IAlmeApiSettings } from '@alme-es/api-ts/build/Interfaces/IAlmeApiSettings';
import { AlmeApiSettings } from '@alme-es/api-ts/build/AlmeApiSettings';
import { HttpHandler } from '@alme-es/api-ts/build/HttpHandler';
const logger = console;
// construct new settings and change the defaults.
const apiSettings: IAlmeApiSettings = new AlmeApiSettings();
apiSettings.AlmeApiHostname = 'your.AlmeApiDomain.com';
apiSettings.AlmeApiProtocol = 'https://';
const httpHandler: HttpHandler = new HttpHandler(logger, apiSettings);
const almeApi: AlmeApi = new AlmeApi(logger, httpHandler, apiSettings);
export default almeApi;