@markwharton/eh-payroll 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,65 +20,97 @@ const client = new EHClient({
|
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
// Validate credentials
|
|
23
|
-
await client.validateApiKey();
|
|
23
|
+
const validation = await client.validateApiKey();
|
|
24
|
+
if (!validation.ok) throw new Error(validation.error);
|
|
24
25
|
|
|
25
26
|
// Get all employees
|
|
26
|
-
const
|
|
27
|
+
const empResult = await client.getEmployees();
|
|
28
|
+
if (empResult.ok) console.log(empResult.data); // EHAuEmployee[]
|
|
27
29
|
|
|
28
30
|
// Get employees filtered by location
|
|
29
|
-
const
|
|
31
|
+
const filteredResult = await client.getEmployees({ locationId: 5 });
|
|
32
|
+
if (filteredResult.ok) console.log(filteredResult.data); // EHAuEmployee[]
|
|
30
33
|
|
|
31
34
|
// Get roster shifts for a date range (auto-paginates)
|
|
32
|
-
const
|
|
35
|
+
const rosterResult = await client.getRosterShifts('2026-02-03', '2026-02-09');
|
|
36
|
+
if (rosterResult.ok) console.log(rosterResult.data); // EHRosterShift[]
|
|
33
37
|
|
|
34
38
|
// Get roster shifts with filters
|
|
35
|
-
const
|
|
39
|
+
const pubResult = await client.getRosterShifts('2026-02-03', '2026-02-09', {
|
|
36
40
|
employeeId: 42,
|
|
37
41
|
shiftStatus: 'Published',
|
|
38
42
|
selectAllRoles: true
|
|
39
43
|
});
|
|
44
|
+
if (pubResult.ok) console.log(pubResult.data); // EHRosterShift[]
|
|
40
45
|
|
|
41
46
|
// Get business locations
|
|
42
|
-
const
|
|
47
|
+
const locResult = await client.getLocations();
|
|
48
|
+
if (locResult.ok) console.log(locResult.data); // EHLocation[]
|
|
43
49
|
|
|
44
50
|
// List kiosks
|
|
45
|
-
const
|
|
51
|
+
const kioskResult = await client.getKiosks();
|
|
52
|
+
if (kioskResult.ok) console.log(kioskResult.data); // EHKiosk[]
|
|
46
53
|
|
|
47
54
|
// Get kiosk staff (time and attendance)
|
|
48
|
-
const
|
|
55
|
+
const staffResult = await client.getKioskStaff(kioskId);
|
|
56
|
+
if (staffResult.ok) console.log(staffResult.data); // EHKioskEmployee[]
|
|
49
57
|
|
|
50
58
|
// Get employee groups
|
|
51
|
-
const
|
|
59
|
+
const groupResult = await client.getEmployeeGroups();
|
|
60
|
+
if (groupResult.ok) console.log(groupResult.data); // EHEmployeeGroup[]
|
|
52
61
|
|
|
53
62
|
// Get standard hours for an employee (includes FTE value)
|
|
54
|
-
const
|
|
63
|
+
const hoursResult = await client.getStandardHours(employeeId);
|
|
64
|
+
if (hoursResult.ok) console.log(hoursResult.data); // EHStandardHours
|
|
55
65
|
|
|
56
66
|
// Discover available report columns
|
|
57
|
-
const
|
|
67
|
+
const fieldsResult = await client.getReportFields();
|
|
68
|
+
if (fieldsResult.ok) console.log(fieldsResult.data); // EHReportField[]
|
|
58
69
|
|
|
59
70
|
// Run Employee Details Report with selected columns
|
|
60
|
-
const
|
|
71
|
+
const reportResult = await client.getEmployeeDetailsReport({
|
|
61
72
|
selectedColumns: ['FirstName', 'Surname', 'ExternalId']
|
|
62
73
|
});
|
|
74
|
+
if (reportResult.ok) console.log(reportResult.data); // Record<string, unknown>[]
|
|
63
75
|
```
|
|
64
76
|
|
|
65
|
-
##
|
|
77
|
+
## Result Pattern
|
|
78
|
+
|
|
79
|
+
All methods return `Result<T>` objects rather than throwing exceptions. Always check `ok` before accessing `data`:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
interface Result<T> {
|
|
83
|
+
ok: boolean;
|
|
84
|
+
data?: T; // present when ok is true
|
|
85
|
+
error?: string; // present when ok is false
|
|
86
|
+
status?: number; // HTTP status code on error
|
|
87
|
+
}
|
|
88
|
+
```
|
|
66
89
|
|
|
67
|
-
|
|
90
|
+
```typescript
|
|
91
|
+
const result = await client.getEmployees();
|
|
92
|
+
if (!result.ok) {
|
|
93
|
+
console.error(result.error, result.status);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const employees = result.data;
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## API Reference
|
|
68
100
|
|
|
69
101
|
| Method | Parameters | Returns |
|
|
70
102
|
|--------|-----------|---------|
|
|
71
|
-
| `validateApiKey()` | — | `
|
|
72
|
-
| `getEmployees(options?)` | `EHEmployeeOptions?` | `
|
|
73
|
-
| `getEmployee(employeeId)` | `number` | `
|
|
74
|
-
| `getStandardHours(employeeId)` | `number` | `
|
|
75
|
-
| `getLocations()` | — | `
|
|
76
|
-
| `getEmployeeGroups()` | — | `
|
|
77
|
-
| `getRosterShifts(from, to, options?)` | `string, string, EHRosterShiftOptions?` | `
|
|
78
|
-
| `getKiosks()` | — | `
|
|
79
|
-
| `getKioskStaff(kioskId, options?)` | `number, EHKioskStaffOptions?` | `
|
|
80
|
-
| `getReportFields()` | — | `
|
|
81
|
-
| `getEmployeeDetailsReport(options?)` | `EHEmployeeDetailsReportOptions?` | `
|
|
103
|
+
| `validateApiKey()` | — | `Result<void>` |
|
|
104
|
+
| `getEmployees(options?)` | `EHEmployeeOptions?` | `Result<EHAuEmployee[]>` |
|
|
105
|
+
| `getEmployee(employeeId)` | `number` | `Result<EHAuEmployee>` |
|
|
106
|
+
| `getStandardHours(employeeId)` | `number` | `Result<EHStandardHours>` |
|
|
107
|
+
| `getLocations()` | — | `Result<EHLocation[]>` |
|
|
108
|
+
| `getEmployeeGroups()` | — | `Result<EHEmployeeGroup[]>` |
|
|
109
|
+
| `getRosterShifts(from, to, options?)` | `string, string, EHRosterShiftOptions?` | `Result<EHRosterShift[]>` |
|
|
110
|
+
| `getKiosks()` | — | `Result<EHKiosk[]>` |
|
|
111
|
+
| `getKioskStaff(kioskId, options?)` | `number, EHKioskStaffOptions?` | `Result<EHKioskEmployee[]>` |
|
|
112
|
+
| `getReportFields()` | — | `Result<EHReportField[]>` |
|
|
113
|
+
| `getEmployeeDetailsReport(options?)` | `EHEmployeeDetailsReportOptions?` | `Result<Record<string, unknown>[]>` |
|
|
82
114
|
|
|
83
115
|
### `getRosterShifts()`
|
|
84
116
|
|