WCF Astrum
API for WFM using WCF protocol
Installation
Install via npm
npm install wcf-astrum
or via yarn
yarn add wcf-astrum
Usage
const wcf =
Context
This module is Astrum specific and is used to communicate with their API (with WCF). The module is split into seperate modules and modules (objects) are going to be added incrementally. Below each api method with abstract explanation of what they do.
Configuration
Configuration needs to be set globally before trying to call any API functions. It is required to define contracts and schemas. Every api method will throw an error if the correct namespace or contract key was not found.
setConfig({ schemas, contracts })
Sets the global configuration.
;
getConfig()
Returns the globally set configuration.
Available API
All available api methods are nested under an object. For example if you wish to get a session you need to call it under the auth
object.
Example:
;auth;
Auth
getSession(proxy, username, password)
returns a session with WCF, this session is used to retrieve resources
endSession(proxy, session)
kills the given session
getIdFromName(proxy, session, context, key)
Get the id using a name
Employee
getEmployees(proxy, session)
returns all employees
Schedule
getSchedule(proxy, session, employeeId, fromDate, toDate)
returns the schedule for given employee and date range
getDepartmentSchedule(proxy, session, employeeIds, fromDate, toDate)
Returns the departmentSchedule for given employeeIds
getAvailabilities(proxy, session, employeeId, fromDate, toDate)
Returns the availabilities for given employee
Info
getSpxObject(proxy, session, id, type)
Returns an spx object with more info
getEmployeeIdsInDepartment(proxy, session, departmentId, startDate, endDate)
Returns all the employee ids for given departmentId and date range
Tests
- You can run
npm run test
to run all tests - You can run
npm run test:coverage
to run all tests with coverage report
External tests - contract testing
- You can run
npm run test:external
to run all test + the external contract tests
These tests will test the actual responses coming back from the WCF application. It will perform real API calls and expect that the response object properties match.
You need to provide all proper environment variables defined in
.env.test.example
. This has been done for security purposes.