@elodigit/client
v0.1.6
Published
ELO Digital Office REST API Client
Downloads
1
Readme
Features
✅ Typescript support
✅ Node.js and browser support
✅ Easy to use and setup with npm
✅ All enpoints available
✅ Reuse of existing browser sessions
✅ Async/await support
Installation
npm install @elodigit/client
Usage
Import and initialize a client using ELO login credentials.
import { Client } from "@elodigit/client";
// Initializing a client
const client = new Client({
IX_URL: "http://playground.com/ix-Solutions",
USERNAME: "Administrator",
PASSWORD: "elo",
});
await client.connect();
OR reuse an existing ELO session (only available in browsers for e.g. web apps)
const client = new Client({
IX_URL: "http://playground.com/ix-Solutions",
USE_SESSION: true,
REDIRECT: true,
});
await client.connect();
Make a request to any ELO API service/endpoint.
See the complete list of endpoints in the IX API Documentation
const response = await client.ix.checkoutSord({
objId: "1",
editInfoZ: EditInfoC.mbSord,
lockZ: LockC.NO,
});
const sord = response.result?.sord;
Each method returns a Promise which resolves the response.
console.log(response);
{
result: {
sord: {
TStamp: "2023.02.24.10.48.35",
acl: "75PYJA",
childCount: 0,
doc: 33,
guid: "(804CE708-8221-716F-7452-4FA201E7F858)",
id: 1,
kind: 1,
mask: 0,
name: "Solutions",
ownerId: 0,
parentId: 1,
...
}
}
}
Client options
The Client
supports the following options on initialization. These options are all keys in the single constructor parameter.
| Option | Default value | Type | Required | Description |
| ------------------ | ----------------------------------------- | -------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| IX_URL
| undefined
| string
| true
| Url to the IX service for connection e.g. https://playground.com/ix-Solutions |
| USERNAME
| undefined
| string
| Resolver
| false
| ELO username for basic authentication. This authentication method is discouraged in the browser because there is no CSRF protection. |
| PASSWORD
| undefined
| string
| Resolver
| false
| ELO password for basic authentication |
| TIMEOUT
| 10000
| number
| false
| Connection timeout to ELO server in ms. |
| USE_SESSION
| false
| boolean
| false
| Reuses an existing session that's provided by e.g. the Java Client, Web Client, Mobile Client. This option is only available in browsers (e.g. for web apps) |
| REDIRECT
| true
| boolean
| false
| Redirects to the login page if session expires. Works only in combination with USE_SESSION
|
| KEEP_ALIVE
| true
| boolean
| false
| Tries to keep the session alive by pinging the server every 60 seconds. Works only in combination with USE_SESSION
or SESSION_TICKET
|
| CLIENT_INFO
| language=en
country=US
timezone=UTC
| ClientInfo
| Resolver
| false
| The ClientInfo
object containing the users language and country |
| ELO_APPROVED
| undefined
| string
| Resolver
| false
| CSRF token to send approved REST requests |
| WITH_CREDENTIALS
| true
| boolean
| false
| Option is used to include cookies in the request. Required for option USE_SESSION
|
| SESSION_TICKET
| undefined
| string
| Resolver
| false
| Session ticket that is used as Bearer-Header for authentication |
| HEADERS
| undefined
| Headers
| Resolver
| false
| Additional custom headers for request |
Resolver
are async functions that can be passed instead of static values to the client. They provide the ability of resolving values at runtime.
async (options: ApiRequestOptions, config: OpenAPIConfig) => {
return "Administrator";
};
Enable CORS
To enabled CORS add the "Access-Control-Allow-*" headers as entries in the Indexserver config.xml. At least "Access-Control-Allow-Origin" is requried. Example:
<entry key="Access-Control-Allow-Origin">*</entry>
TypeScript
This package contains type definitions for all request parameters and responses.
Constants
All ELO constants are available for e.g. endpoint requests. LockC.NO, SordC.mbAllIndex, etc.