@icapps/wcf-astrum
v0.33.2
Published
API for WFM using WCF protocol
Downloads
21
Maintainers
Keywords
Readme
WCF Astrum
API for WFM using WCF protocol
Installation
Install via npm
npm install @icapps/wcf-astrum
or via yarn
yarn add @icapps/wcf-astrum
Usage
const wcf = require('@icapps/wcf-astrum');
import * as wcf from '@icapps/wcf-astrum';
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.
setConfig({
contracts: {
v1: 'v1 contract',
},
schemas: {
defaultSchema: 'default schema',
},
});
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:
import { auth } from '@icapps/wcf-astrum';
auth.getSession(...);
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, filters, scheduleLevel)
Returns the availabilities for given employee
writeAvailabilities(proxy, session, departmentId, employeeId, availabilityShiftId, entries, scheduleLevel)
Write an availability
writeAbsence(proxy, session, departmentId, employeeId, shiftId, startDay, endDay, scheduleLevel, operation, schoolShiftId, availabilityShiftId)
Write an absence for a full day
writeAbsenceInterval(proxy, session, departmentId, employeeId,absenceIntervalId, day, from, to, notOverwriteableTimeTypes)
Write an absence for an interval
checkVacationRequestRuleViolation(proxy, session, employeeId, shiftId, fromDate, untilDate)
Check if the vacation request has a rule violation
checkScheduleRuleViolation(proxy, session, employeeId, shifts, date)
Check if there is a rule violation on write schedule
writeShiftOffer(proxy, session, departmentId, employeeId, shifts, date)
Write a shift offer
Time Registration
getCorrections(proxy, session, employeeId, filters)
Get time registrations for an employee id
saveCorrection(proxy, session, employeeId, eventType, timestamp)
Save a time registrations for an employee
Counters
getCounters(proxy: IProxy, session: ISession, employeeId: string, counterIds: string[], startdate: string, endDate: string)
Return all balance valuse for a given employee id and date range
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.