node effektif api
This project is inactive. Effektif was accuired by Signavio so the project has moved to signavio-api.
Unofficial node effektif api wrapper.
Table of contents
Introduction
The module is auto-generated from the effektif documentation json-endpoint.
Interface
All Api-endpoints are represented.
Constructor
The interface constructor takes an object with options.
options
: Object with the following properties:authorization
: optional string - Authorization token, will be set as Authorization http headercredentials
: optional object - Default credentialsusername
: string - Usernamepassword
: string - Password
basePath
: optional string - Effektif-api base url, defaults to api endpoint documentation basePathbaseRequest
: optional - Default requestlog
: optional - Logging function, defaults to console.logusers
: optional - Users instanceonUnauthorized
: optional function that will be called when an unauthorized call is made
Example:
const request = ; const Api = ;const Users = User; const baseRequest = request; const workflows = authorization: 'token' credentials: username: 'me@example.com' password: 'sup3rs3cr3t' basePath: 'http://effektif-cluster.local/api' baseRequest: baseRequest;
onUnauthorized
option
Optional function used to get user authorization token. The function is called when an unauthorized call was made. If a token is returned in callback the operation will be called with then new authorization token. The function is bound to the module instance on execution, i.e. this
can be used to access module options.
The function signature is:
operationArguments
: The actual operation argumentscallback
:error
: Error if anytoken
: The new authorization token to use
Example:
const db = ; // Arbitrary database module { db;} let workflows = onUnauthorized: onUnauthorized credentials: username: 'me@example.com' ;
#getUserInstance
A User instance is created with the same options as the module and this is the function to retrieve it.
Example usage:
const Api = ; { let users = this; let loginOptions = {}; if operationArgsorganizationKey loginOptionsorganizationKey = operationArgsorganizationKey; users;} const workflows = basePath: 'https://effektif.local/api';
Events
All interfaces inherit from EventEmitter.
authorized
The authorized
event is emitted when a succesfull login was performed.
The listener function will get username
and authorization
-token.
const Api = ; let workflows = credentials: username: 'me@example.com' password: 'sup3rs3cr3t' ; workflows;
Tasks
const Api = ; const Tasks = ApiTask;const tasks = authorization: 'token'; tasks;
#getFormFieldByName
Utility function to get FormField by name from task data.
const Api = ; const Tasks = ApiTask;const tasks = authorization: 'token'; tasks;
Users
const Api = ; const Tasks = ApiTask;const tasks = authorization: 'token' credentials: username: 'me@example.com' password: 'sup3rs3cr3t' ; tasks;
#login
Utility function to perform user login.
const Api = ;const users = ; users;
API Generator
Module functions are generated from the api-endpoints.
Naming of operations
The name is composed of the http-operation and the api-endpoint.
HTTP-verb | function prefix |
---|---|
GET |
get |
POST |
create |
PUT |
update |
DELETE |
delete |
Examples:
To call POST /{organizationKey}/tasks
:
const Api = ;const tasks = authorization: 'token'; let newTask = {}; tasks;
or DELETE /{organizationKey}/workflows/{editorWorkflowId}
:
const Api = ;const workflows = authorization: 'token'; workflows;
The plural ending is removed if the noun is immediately followed by a path parameter.
Path parameters
The path parameters will build the method signature. They are considered required.
Query parameters
The query parameters will also be appended to the method signature. All query parametes are considered optional in get-operations.
const Api = ;const workflows = authorization: 'token'; workflows;
If a body is expected, the query parameters must be defined. Since they are optional, a null
value is accepted.
Input Schemas
The operation schemas (joi) are stored with the module.
const Api = ;const inputSchema = ApiWorkflowschemasgetWorkflowinput; console; const outputSchema = ApiWorkflowschemasgetWorkflowoutput; console;
The schemas are also stored with the instance methods.
const Api = ;const workflows = authorization: 'token'; console;
Operation callback
All operations takes callback as final argument. The callback is required.
error
: Error or null. Api-calls with a http response status code above 399 will be considered an errorresult
: Operation resulthttpResponse
: The HTTP response from the call to the actual api. Should be returned even if an error has occurred
Debug
The module uses debug so run with environment variable DEBUG=effektif-api*
.