Functions
This document explains all the functions of eLegere Script.
Abstract
Each function section includes:
- The syntax of the function.
- The parameters of the function.
- What the function returns.
Logging Functions¶
Logging functions are used to show various notifications to the eLegere user. They can also be used by the designers to debug their application.
logInfo void
¶
Description¶
1 |
|
The function creates a void object. The function shows the object to the user that triggered the script through the info notification.
Parameters¶
arg
any The value shown the user inside the notification's body. If the value is an object or array, it will be stringified through JSON.stringify().
logError void
¶
Description¶
1 |
|
The function creates a void object. The function shows the object through an error notification to the user that triggered the script.
Parameters¶
arg
any The value shown to the user inside the notification's body. If the value is an object or array, it will be stringified through JSON.stringify().
logDebug void
¶
Description¶
1 |
|
The function creates a void object. The function shows the object through a debug notification to the user that triggered the script.
Parameters¶
arg
any The value shown to the user inside the notification's body. If the value is an object or array, it will be stringified through JSON.stringify().
The elegere
Object¶
The object elegere
initializes Environments, Domains, and Applications objects. These objects perform actions on eLegere applications.
Environment, Domain, and Applications¶
The Environment, Domain, and Applications functions are functions returning new objects Environment, Domain, and Application as result.
As alternative to the parameters, the context object retrieves information from to the logged User and session.
getEnvironment Promise<Environment>
¶
Description¶
1 |
|
The function connects to a eLegere instance by authenticating from the URL using username and password as credentials.
For example:
1 |
|
Parameters¶
url
string A URL pointing to the eLegere instance.
username
string Username for logging into the eLegere instance.
password
string Password for logging into the eLegere instance.
Return Value¶
Promise of an Environment object.
getEnvironmentFromToken Promise<Environment>
¶
Description¶
1 |
|
The function connects to a eLegere instance through the URL. Authentication occurs through two tokens: an already valid session token and the token of the domainId. The function returns an Environment object.
For example:
1 |
|
Parameters¶
url
string URL pointing to the eLegere instance.
sessionToken
string Session token of the login. The function uses the session token to authenticate and perform actions in the Environment.
domainId
string A string of random characters identifying the Domain in which the actual session is running.
Return Value¶
Promise of an Environment object.
getApplication Promise<Application>
¶
1 |
|
The function identifies a specific Application of eLegere. Identification works through Application ID and Domain ID after authentication with username and password.
For example:
1 |
|
Parameters¶
applicationId
string Id of the Application connected to the APIs.
domainId
string Id of the Domain of the Application.
url
string Url pointing to the eLegere instance.
username
string Username that the function employs for logging in.
password
string Password that the function employs for logging in.
Return Value¶
A Promise for an Application object.
getApplicationFromToken Promise<Application>
¶
1 |
|
The function identifies a specific Application of eLegere. Identification works through Application ID and Domain ID after authentication through the Session Token.
For example:
1 |
|
Parameters¶
applicationId
string Id of the Application connected to the APIs.
domainId
string Id of the Domain of the Application.
url
string The Url pointing to the eLegere instance.
sessionToken
string The Session Token that the function employs for logging in.
Return Value¶
A Promise for an Application object.
HTTP Request Helpers¶
The Http Request Helpers are functions that process endpoints of APIs.
eLegere scripts also include helper function for making GET/POST http requests to external APIs.
get Promise<any>
¶
1 |
|
Performs a GET request to URL supplied.
For example:
1 |
|
Parameters¶
url
string The Url to which the function sends the request.
config
object The list of the configuration parameters requested. The parameter includes:
- "header" It sends a HTTP request including the headers. Each key in the header object stands for the header key. Each value correspond to the value in the header object.
- "auth" If the user needs authentication through Basic HTTP, it supplies username and password. This parameter overrides any Authorization header.
Return Value¶
A Promise to wait any sort of Object when ready.
post Promise<any>
¶
1 |
|
Performs a POST request to the URL supplied.
For example:
1 |
|
Parameters¶
url
string The Url to which the function sends the request.
data
object The data that the functions includes in the request body.
config
object The list of the configuration parameters requested. The parameter includes:
- "header" It sends a HTTP request including the headers. Each key in the header object stands for the header key. Each value correspond to the value in the header object.
- "auth" If the user needs authentication through Basic HTTP, it supplies username and password. This parameter overrides any Authorization header.
Return Value¶
A Promise to wait any sort of Object when ready.
Date Time Converters¶
Date functions simplify the conversion from standard formats to eLegere date format.
Users can find the required offset in milliseconds through the context TimezoneMSOffset object.
datetimeToNumber number
¶
1 |
|
Converts a JavaScript date to a 14-digit eLegere date.
An Example:
1 2 3 |
|
Parameters¶
date
Date The original JavaScript date that the function takes.
Return Value¶
The function yields the original date in the 14-digit eLegere format.
numberToDatetime Date
¶
1 |
|
Converts the 14-digit eLegere date into a JavaScript date.
An Example:
1 2 3 |
|
Parameters¶
elegereDate
number The date in eLegere format that the function converts in JavaScript date format.
Return Value¶
The function yields the date in JavaScript format.
NumberEstToUtc number
¶
1 |
|
The function converts eLegere Eastern Standard Time date in custom format (14-digits) to UTC time zone.
For example:
1 |
|
Parameters¶
elegereDate
number The Est date in eLegere custom format (14-digits) that the function converts in UTC date format.
timezoneOffset
number The millisecond offset value of the source time zone.
Return Value¶
The function yields the eLegere date in UTC time zone.
NumberUtcToEst Date
¶
1 |
|
The function converts eLegere UTC date in custom format (14-digits) to Est time zone.
For example:
1 |
|
Parameters¶
elegereDate
number The Est date in eLegere custom format (14-digits) that the function converts in Est date format.
timezoneOffset
number The millisecond offset value of the source time zone.
Return value¶
The function yields the eLegere date in Est time zone.
datetimeEstToUtc Date
¶
1 |
|
The function converts a Est JavaScript date format in UTC time zone. The function considers the source time zone's milliseconds offset.
For example:
1 |
|
Parameters¶
date
Date The original JavaScript date that the function takes for conversion.
timezoneOffset
number The millisecond offset value of the source time zone.
Return Value¶
The function yields the eLegere date in UTC time zone format.
dateTimeUTCtoEst Date
¶
1 |
|
The function converts a UTC JavaScript date format in Est time zone. The function considers the source time zone's milliseconds offset.
For example:
1 |
|
Parameters¶
date
number The JavaScript date that the function takes for conversion.
timezoneOffset
number The millisecond offset value of the source time zone.
Return Value¶
The function yields the JavaScript date in Est time zone.