rotacloud 1.0.48 → 1.0.51

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.
Files changed (102) hide show
  1. package/dist/cjs/interfaces/index.d.ts +4 -0
  2. package/dist/cjs/interfaces/index.js +4 -0
  3. package/dist/cjs/interfaces/logbook-category.interface.d.ts +1 -0
  4. package/dist/cjs/interfaces/pin.interface.d.ts +3 -0
  5. package/dist/cjs/interfaces/pin.interface.js +2 -0
  6. package/dist/cjs/interfaces/terminal.interface.d.ts +20 -0
  7. package/dist/cjs/interfaces/terminal.interface.js +2 -0
  8. package/dist/cjs/interfaces/user.interface.d.ts +8 -1
  9. package/dist/cjs/interfaces/users-clocked-in.interface.d.ts +13 -0
  10. package/dist/cjs/interfaces/users-clocked-in.interface.js +2 -0
  11. package/dist/cjs/interfaces/users-clocked-out.interface.d.ts +26 -0
  12. package/dist/cjs/interfaces/users-clocked-out.interface.js +2 -0
  13. package/dist/cjs/models/attendance.model.d.ts +5 -5
  14. package/dist/cjs/models/availability-pattern.model.js +12 -0
  15. package/dist/cjs/models/daily-revenue.model.js +3 -0
  16. package/dist/cjs/models/index.d.ts +2 -0
  17. package/dist/cjs/models/index.js +2 -0
  18. package/dist/cjs/models/logbook-category.model.d.ts +1 -1
  19. package/dist/cjs/models/logbook-category.model.js +2 -0
  20. package/dist/cjs/models/terminal.model.d.ts +7 -6
  21. package/dist/cjs/models/terminal.model.js +14 -0
  22. package/dist/cjs/models/users-clocked-in.model.d.ts +14 -0
  23. package/dist/cjs/models/users-clocked-in.model.js +19 -0
  24. package/dist/cjs/models/users-clocked-out.model.d.ts +27 -0
  25. package/dist/cjs/models/users-clocked-out.model.js +31 -0
  26. package/dist/cjs/rotacloud.d.ts +7 -4
  27. package/dist/cjs/rotacloud.js +7 -4
  28. package/dist/cjs/services/index.d.ts +6 -1
  29. package/dist/cjs/services/index.js +6 -1
  30. package/dist/cjs/services/pins.service.d.ts +11 -0
  31. package/dist/cjs/services/pins.service.js +16 -0
  32. package/dist/cjs/services/terminals-active.service.d.ts +35 -0
  33. package/dist/cjs/services/terminals-active.service.js +103 -0
  34. package/dist/cjs/services/terminals.service.d.ts +32 -0
  35. package/dist/cjs/services/terminals.service.js +108 -0
  36. package/dist/cjs/services/users-clock-in.service.d.ts +62 -0
  37. package/dist/cjs/services/users-clock-in.service.js +118 -0
  38. package/dist/cjs/version.js +1 -1
  39. package/dist/mjs/interfaces/index.d.ts +4 -0
  40. package/dist/mjs/interfaces/index.js +4 -0
  41. package/dist/mjs/interfaces/logbook-category.interface.d.ts +1 -0
  42. package/dist/mjs/interfaces/pin.interface.d.ts +3 -0
  43. package/dist/mjs/interfaces/pin.interface.js +1 -0
  44. package/dist/mjs/interfaces/terminal.interface.d.ts +20 -0
  45. package/dist/mjs/interfaces/terminal.interface.js +1 -0
  46. package/dist/mjs/interfaces/user.interface.d.ts +8 -1
  47. package/dist/mjs/interfaces/users-clocked-in.interface.d.ts +13 -0
  48. package/dist/mjs/interfaces/users-clocked-in.interface.js +1 -0
  49. package/dist/mjs/interfaces/users-clocked-out.interface.d.ts +26 -0
  50. package/dist/mjs/interfaces/users-clocked-out.interface.js +1 -0
  51. package/dist/mjs/models/attendance.model.d.ts +5 -5
  52. package/dist/mjs/models/availability-pattern.model.js +12 -0
  53. package/dist/mjs/models/daily-revenue.model.js +3 -0
  54. package/dist/mjs/models/index.d.ts +2 -0
  55. package/dist/mjs/models/index.js +2 -0
  56. package/dist/mjs/models/logbook-category.model.d.ts +1 -1
  57. package/dist/mjs/models/logbook-category.model.js +1 -0
  58. package/dist/mjs/models/terminal.model.d.ts +7 -6
  59. package/dist/mjs/models/terminal.model.js +14 -0
  60. package/dist/mjs/models/users-clocked-in.model.d.ts +14 -0
  61. package/dist/mjs/models/users-clocked-in.model.js +14 -0
  62. package/dist/mjs/models/users-clocked-out.model.d.ts +27 -0
  63. package/dist/mjs/models/users-clocked-out.model.js +26 -0
  64. package/dist/mjs/rotacloud.d.ts +7 -4
  65. package/dist/mjs/rotacloud.js +7 -4
  66. package/dist/mjs/services/index.d.ts +6 -1
  67. package/dist/mjs/services/index.js +6 -1
  68. package/dist/mjs/services/pins.service.d.ts +11 -0
  69. package/dist/mjs/services/pins.service.js +12 -0
  70. package/dist/mjs/services/terminals-active.service.d.ts +35 -0
  71. package/dist/mjs/services/terminals-active.service.js +43 -0
  72. package/dist/mjs/services/terminals.service.d.ts +32 -0
  73. package/dist/mjs/services/terminals.service.js +48 -0
  74. package/dist/mjs/services/users-clock-in.service.d.ts +62 -0
  75. package/dist/mjs/services/users-clock-in.service.js +57 -0
  76. package/dist/mjs/version.js +1 -1
  77. package/package.json +2 -2
  78. package/src/interfaces/index.ts +4 -0
  79. package/src/interfaces/logbook-category.interface.ts +1 -0
  80. package/src/interfaces/pin.interface.ts +16 -0
  81. package/src/interfaces/terminal.interface.ts +21 -0
  82. package/src/interfaces/user.interface.ts +9 -1
  83. package/src/interfaces/users-clocked-in.interface.ts +14 -0
  84. package/src/interfaces/users-clocked-out.interface.ts +27 -0
  85. package/src/models/attendance.model.ts +5 -5
  86. package/src/models/availability-pattern.model.ts +12 -0
  87. package/src/models/daily-revenue.model.ts +3 -0
  88. package/src/models/days-off.model.ts +1 -0
  89. package/src/models/index.ts +2 -0
  90. package/src/models/logbook-category.model.ts +2 -1
  91. package/src/models/terminal.model.ts +21 -6
  92. package/src/models/toil-accrual.model.ts +1 -0
  93. package/src/models/toil-allowance.model.ts +1 -0
  94. package/src/models/users-clocked-in.model.ts +27 -0
  95. package/src/models/users-clocked-out.model.ts +52 -0
  96. package/src/rotacloud.ts +11 -3
  97. package/src/services/index.ts +6 -1
  98. package/src/services/pins.service.ts +16 -0
  99. package/src/services/terminals-active.service.ts +75 -0
  100. package/src/services/terminals.service.ts +78 -0
  101. package/src/services/users-clock-in.service.ts +125 -0
  102. package/src/version.ts +1 -1
@@ -0,0 +1,14 @@
1
+ import { ApiShift, ApiTerminalLocation } from '../interfaces/index.js';
2
+
3
+ export interface ApiUserClockedIn {
4
+ user: number;
5
+ location: number;
6
+ role: number;
7
+ in_time: number;
8
+ minutes_late: number;
9
+ shift: Pick<ApiShift, 'id' | 'start_time' | 'end_time' | 'minutes_break' | 'location' | 'role'>;
10
+ in_method: string;
11
+ in_location: ApiTerminalLocation;
12
+ in_device: string | null;
13
+ in_terminal: number | null;
14
+ }
@@ -0,0 +1,27 @@
1
+ import { ApiShift, ApiTerminalLocation } from './index.js';
2
+
3
+ export interface ApiUserClockedOut {
4
+ id: number;
5
+ deleted: boolean;
6
+ approved: boolean;
7
+ user: number;
8
+ location: number;
9
+ role: number;
10
+ in_time: number;
11
+ out_time: number;
12
+ minutes_break: number;
13
+ minutes_late: number;
14
+ hours: number;
15
+ hours_auto: number;
16
+ hours_is_auto: boolean;
17
+ notes: string | null;
18
+ shift: Pick<ApiShift, 'id' | 'start_time' | 'end_time' | 'minutes_break' | 'location' | 'role'>;
19
+ in_method: string;
20
+ in_location: ApiTerminalLocation;
21
+ in_device: string | null;
22
+ in_terminal: number | null;
23
+ out_method: string;
24
+ out_location: ApiTerminalLocation;
25
+ out_device: string | null;
26
+ out_terminal: number | null;
27
+ }
@@ -1,4 +1,4 @@
1
- import { ApiAttendance, ApiAttendanceLocation, ApiShift } from '../interfaces/index.js';
1
+ import { ApiAttendance, ApiTerminalLocation, ApiShift } from '../interfaces/index.js';
2
2
 
3
3
  export class Attendance {
4
4
  public id: number;
@@ -18,12 +18,12 @@ export class Attendance {
18
18
  public shift: ApiShift | null;
19
19
  public in_method: string;
20
20
  public out_method: string;
21
- public in_location: ApiAttendanceLocation;
22
- public out_location: ApiAttendanceLocation;
21
+ public in_location: ApiTerminalLocation;
22
+ public out_location: ApiTerminalLocation;
23
23
  public in_device: number;
24
24
  public out_device: number;
25
- public in_terminal: null;
26
- public out_terminal: null;
25
+ public in_terminal: number | null;
26
+ public out_terminal: number | null;
27
27
 
28
28
  constructor(attendance: ApiAttendance) {
29
29
  this.id = attendance.id;
@@ -17,5 +17,17 @@ export class AvailabilityPattern {
17
17
 
18
18
  constructor(apiAvailabilityPatterns: ApiAvailabilityPattern) {
19
19
  this.id = apiAvailabilityPatterns.id;
20
+ this.user = apiAvailabilityPatterns.user;
21
+ this.name = apiAvailabilityPatterns.name;
22
+ this.start_date = apiAvailabilityPatterns.start_date;
23
+ this.end_date = apiAvailabilityPatterns.end_date;
24
+ this.repeat_weeks = apiAvailabilityPatterns.repeat_weeks;
25
+ this.mon = apiAvailabilityPatterns.mon;
26
+ this.tue = apiAvailabilityPatterns.tue;
27
+ this.wed = apiAvailabilityPatterns.wed;
28
+ this.thu = apiAvailabilityPatterns.thu;
29
+ this.fri = apiAvailabilityPatterns.fri;
30
+ this.sat = apiAvailabilityPatterns.sat;
31
+ this.sun = apiAvailabilityPatterns.sun;
20
32
  }
21
33
  }
@@ -10,5 +10,8 @@ export class DailyRevenue {
10
10
  constructor(dailyRevenue: ApiDailyRevenue) {
11
11
  this.date = dailyRevenue.date;
12
12
  this.location = dailyRevenue.location;
13
+ this.labour_percentage = dailyRevenue.labour_percentage;
14
+ this.revenue_target = dailyRevenue.revenue_target;
15
+ this.revenue_actual = dailyRevenue.revenue_actual;
13
16
  }
14
17
  }
@@ -3,6 +3,7 @@ import { ApiDaysOff, ApiDayOff } from '../interfaces/index.js';
3
3
  export class DaysOff {
4
4
  public user: number;
5
5
  public dates: ApiDayOff[];
6
+
6
7
  constructor(daysoff: ApiDaysOff) {
7
8
  this.user = daysoff.user;
8
9
  this.dates = daysoff.dates;
@@ -29,3 +29,5 @@ export * from './terminal.model.js';
29
29
  export * from './toil-accrual.model.js';
30
30
  export * from './toil-allowance.model.js';
31
31
  export * from './user.model.js';
32
+ export * from './users-clocked-in.model.js';
33
+ export * from './users-clocked-out.model.js';
@@ -3,10 +3,11 @@ import { ApiLogbookCategory } from '../interfaces/index.js';
3
3
  export class LogbookCategory {
4
4
  public id: number;
5
5
  public name: string;
6
- public deleted: boolean;
6
+ public deleted: boolean | null;
7
7
 
8
8
  constructor(logbookCategory: ApiLogbookCategory) {
9
9
  this.id = logbookCategory.id;
10
10
  this.name = logbookCategory.name;
11
+ this.deleted = logbookCategory.deleted ?? null;
11
12
  }
12
13
  }
@@ -1,16 +1,31 @@
1
- import { ApiLocationCoordinate } from '../interfaces/index.js';
1
+ import { ApiLocationCoordinate, ApiTerminal } from '../interfaces/index.js';
2
2
 
3
3
  export class Terminal {
4
4
  public id: number;
5
5
  public deleted: boolean;
6
6
  public name: string;
7
7
  public active: boolean;
8
- public type: string;
9
- public device: string;
10
- public version: string;
11
- public ip: string;
12
- public location: ApiLocationCoordinate;
8
+ public platform: string | null;
9
+ public device: string | null;
10
+ public version: string | null;
11
+ public ip: string | null;
12
+ public location: ApiLocationCoordinate | null;
13
13
  public timezone: number;
14
14
  public require_photo: boolean;
15
15
  public require_photo_breaks: boolean;
16
+
17
+ constructor(terminal: ApiTerminal) {
18
+ this.id = terminal.id;
19
+ this.deleted = terminal.deleted;
20
+ this.name = terminal.name;
21
+ this.active = terminal.active;
22
+ this.platform = terminal.platform;
23
+ this.device = terminal.device;
24
+ this.version = terminal.version;
25
+ this.ip = terminal.ip;
26
+ this.location = terminal.location;
27
+ this.timezone = terminal.timezone;
28
+ this.require_photo = terminal.require_photo;
29
+ this.require_photo_breaks = terminal.require_photo_breaks;
30
+ }
16
31
  }
@@ -13,6 +13,7 @@ export class ToilAccrual {
13
13
  public leave_year: number;
14
14
  public location_id: number | null;
15
15
  public user_id: number;
16
+
16
17
  constructor(accrual: ApiToilAccrual) {
17
18
  this.comments = accrual.comments;
18
19
  this.created_at = accrual.created_at;
@@ -6,6 +6,7 @@ export class ToilAllowance {
6
6
  public remaining_hours: number;
7
7
  public used_hours: number;
8
8
  public has_toil_records: boolean;
9
+
9
10
  constructor(allowance: ApiToilAllowance) {
10
11
  this.user = allowance.user;
11
12
  this.accrued_hours = allowance.accrued_hours;
@@ -0,0 +1,27 @@
1
+ import { ApiUserClockedIn, ApiShift, ApiTerminalLocation } from '../interfaces/index.js';
2
+
3
+ export class UserClockedIn {
4
+ public user: number;
5
+ public location: unknown; // todo
6
+ public role: number;
7
+ public in_time: number;
8
+ public minutes_late: number;
9
+ public shift: Pick<ApiShift, 'id' | 'start_time' | 'end_time' | 'minutes_break' | 'location' | 'role'>;
10
+ public in_method: string;
11
+ public in_location: ApiTerminalLocation;
12
+ public in_device: string | null;
13
+ public in_terminal: number | null;
14
+
15
+ constructor(apiUserClockedIn: ApiUserClockedIn) {
16
+ this.user = apiUserClockedIn.user;
17
+ this.location = apiUserClockedIn.location;
18
+ this.role = apiUserClockedIn.role;
19
+ this.in_time = apiUserClockedIn.in_time;
20
+ this.minutes_late = apiUserClockedIn.minutes_late;
21
+ this.shift = apiUserClockedIn.shift;
22
+ this.in_method = apiUserClockedIn.in_method;
23
+ this.in_location = apiUserClockedIn.in_location;
24
+ this.in_device = apiUserClockedIn.in_device ?? null;
25
+ this.in_terminal = apiUserClockedIn.in_terminal ?? null;
26
+ }
27
+ }
@@ -0,0 +1,52 @@
1
+ import { ApiShift, ApiTerminalLocation, ApiUserClockedOut } from '../interfaces/index.js';
2
+
3
+ export class UserClockedOut {
4
+ public id: number;
5
+ public deleted: boolean;
6
+ public approved: boolean;
7
+ public user: number;
8
+ public location: unknown; // todo
9
+ public role: number;
10
+ public in_time: number;
11
+ public out_time: number;
12
+ public minutes_break: number;
13
+ public minutes_late: number;
14
+ public hours: number;
15
+ public hours_auto: number;
16
+ public hours_is_auto: number;
17
+ public notes: string | null;
18
+ public shift: Pick<ApiShift, 'id' | 'start_time' | 'end_time' | 'minutes_break' | 'location' | 'role'>;
19
+ public in_method: string;
20
+ public in_location: ApiTerminalLocation;
21
+ public in_device: string | null;
22
+ public in_terminal: number | null;
23
+ public out_method: string;
24
+ public out_location: ApiTerminalLocation;
25
+ public out_device: string | null;
26
+ public out_terminal: number | null;
27
+
28
+ constructor(apiUserClockedOut: ApiUserClockedOut) {
29
+ this.id = apiUserClockedOut.id;
30
+ this.deleted = apiUserClockedOut.deleted;
31
+ this.approved = apiUserClockedOut.approved;
32
+ this.user = apiUserClockedOut.user;
33
+ this.location = apiUserClockedOut.location;
34
+ this.role = apiUserClockedOut.role;
35
+ this.in_time = apiUserClockedOut.in_time;
36
+ this.out_time = apiUserClockedOut.out_time;
37
+ this.minutes_break = apiUserClockedOut.minutes_break;
38
+ this.minutes_late = apiUserClockedOut.minutes_late;
39
+ this.hours = apiUserClockedOut.hours;
40
+ this.hours_auto = apiUserClockedOut.hours_auto;
41
+ this.notes = apiUserClockedOut.notes ?? null;
42
+ this.shift = apiUserClockedOut.shift;
43
+ this.in_method = apiUserClockedOut.in_method;
44
+ this.in_location = apiUserClockedOut.in_location;
45
+ this.in_device = apiUserClockedOut.in_device ?? null;
46
+ this.in_terminal = apiUserClockedOut.in_terminal ?? null;
47
+ this.out_method = apiUserClockedOut.out_method;
48
+ this.out_location = apiUserClockedOut.out_location;
49
+ this.out_device = apiUserClockedOut.out_device ?? null;
50
+ this.out_terminal = apiUserClockedOut.out_terminal ?? null;
51
+ }
52
+ }
package/src/rotacloud.ts CHANGED
@@ -5,23 +5,27 @@ import {
5
5
  AvailabilityService,
6
6
  DailyBudgetsService,
7
7
  DailyRevenueService,
8
+ DayNotesService,
8
9
  DaysOffService,
9
10
  GroupsService,
10
11
  LeaveEmbargoesService,
11
12
  LeaveRequestService,
13
+ LeaveTypesService,
12
14
  LeaveService,
13
15
  LocationsService,
14
16
  RetryStrategy,
15
17
  RolesService,
16
18
  SettingsService,
17
19
  ShiftsService,
20
+ TerminalsService,
21
+ TerminalsActiveService,
18
22
  ToilAccrualsService,
19
23
  ToilAllowanceService,
20
24
  UsersService,
25
+ UsersClockInService,
21
26
  } from './services/index.js';
22
27
  import { SDKConfig } from './interfaces/index.js';
23
- import { DayNotesService } from './services/day-notes.service.js';
24
- import { LeaveTypesService } from './services/leave-types.service.js';
28
+ import { PinsService } from './services/pins.service.js';
25
29
 
26
30
  const DEFAULT_CONFIG: Partial<SDKConfig> = {
27
31
  baseUri: 'https://api.rotacloud.com/v1',
@@ -43,14 +47,18 @@ export class RotaCloud {
43
47
  public group = new GroupsService();
44
48
  public leaveEmbargoes = new LeaveEmbargoesService();
45
49
  public leaveRequests = new LeaveRequestService();
46
- public leave = new LeaveService();
47
50
  public leaveTypes = new LeaveTypesService();
51
+ public leave = new LeaveService();
48
52
  public locations = new LocationsService();
53
+ public pins = new PinsService();
49
54
  public roles = new RolesService();
50
55
  public settings = new SettingsService();
51
56
  public shifts = new ShiftsService();
57
+ public terminals = new TerminalsService();
58
+ public terminalsActive = new TerminalsActiveService();
52
59
  public toilAccruals = new ToilAccrualsService();
53
60
  public toilAllowance = new ToilAllowanceService();
61
+ public usersClockInService = new UsersClockInService();
54
62
  public users = new UsersService();
55
63
 
56
64
  constructor(config: SDKConfig) {
@@ -5,15 +5,20 @@ export * from './auth.service.js';
5
5
  export * from './availability.service.js';
6
6
  export * from './daily-budgets.service.js';
7
7
  export * from './daily-revenue.service.js';
8
+ export * from './day-notes.service.js';
8
9
  export * from './days-off.service.js';
9
10
  export * from './groups.service.js';
10
- export * from './leave-request.service.js';
11
11
  export * from './leave-embargoes.service.js';
12
+ export * from './leave-request.service.js';
13
+ export * from './leave-types.service.js';
12
14
  export * from './leave.service.js';
13
15
  export * from './locations.service.js';
14
16
  export * from './roles.service.js';
15
17
  export * from './settings.service.js';
16
18
  export * from './shifts.service.js';
19
+ export * from './terminals.service.js';
20
+ export * from './terminals-active.service.js';
17
21
  export * from './toil-accruals.service.js';
18
22
  export * from './toil-allowance.service.js';
23
+ export * from './users-clock-in.service.js';
19
24
  export * from './users.service.js';
@@ -0,0 +1,16 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { ApiPin } from '../interfaces/index.js';
3
+ import { Service, Options } from './index.js';
4
+
5
+ export class PinsService extends Service {
6
+ private apiPath = '/pins';
7
+
8
+ get(id: string): Promise<ApiPin>;
9
+ get(id: string, options?: { rawResponse: true } & Options): Promise<AxiosResponse<ApiPin, any>>;
10
+ get(id: string, options?: Options): Promise<ApiPin>;
11
+ get(id: string, options?: Options) {
12
+ return super
13
+ .fetch<ApiPin>({ url: `${this.apiPath}/${id}` }, options)
14
+ .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
15
+ }
16
+ }
@@ -0,0 +1,75 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { ApiTerminal, ApiTerminalLocation } from '../interfaces/index.js';
3
+ import { Service, Options } from './index.js';
4
+
5
+ import { Terminal } from '../models/terminal.model.js';
6
+
7
+ interface LaunchTerminal {
8
+ terminal: number;
9
+ device: string;
10
+ location?: ApiTerminalLocation;
11
+ }
12
+
13
+ interface PingTerminal {
14
+ action: string;
15
+ device: string;
16
+ }
17
+
18
+ class TerminalsActiveService extends Service {
19
+ private apiPath = '/terminals_active';
20
+
21
+ launchTerminal(data: LaunchTerminal): Promise<Terminal>;
22
+ launchTerminal(data: LaunchTerminal, options: { rawResponse: true } & Options): Promise<AxiosResponse<any, any>>;
23
+ launchTerminal(data: LaunchTerminal, options: Options): Promise<Terminal>;
24
+ launchTerminal(data: LaunchTerminal, options?: Options) {
25
+ return super
26
+ .fetch<ApiTerminal>({
27
+ url: `${this.apiPath}`,
28
+ data,
29
+ method: 'POST',
30
+ })
31
+ .then((res) => Promise.resolve(options?.rawResponse ? res : new Terminal(res.data)));
32
+ }
33
+
34
+ pingTerminal(id: number, data: PingTerminal): Promise<number>;
35
+ pingTerminal(
36
+ id: number,
37
+ data: PingTerminal,
38
+ options: { rawResponse: true } & Options
39
+ ): Promise<AxiosResponse<any, any>>;
40
+ pingTerminal(id: number, data: PingTerminal, options: Options): Promise<number>;
41
+ pingTerminal(id: number, data: PingTerminal, options?: Options) {
42
+ return super
43
+ .fetch({ url: `${this.apiPath}/${id}`, data, method: 'POST' })
44
+ .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
45
+ }
46
+
47
+ async *list(options?: Options) {
48
+ for await (const res of super.iterator<ApiTerminal>({ url: this.apiPath }, options)) {
49
+ yield new Terminal(res);
50
+ }
51
+ }
52
+
53
+ listAll(options?: Options): Promise<Terminal[]>;
54
+ async listAll(options?: Options) {
55
+ const users = [] as Terminal[];
56
+ for await (const user of this.list(options)) {
57
+ users.push(user);
58
+ }
59
+ return users;
60
+ }
61
+
62
+ listByPage(options?: Options) {
63
+ return super.iterator<ApiTerminal>({ url: this.apiPath }, options).byPage();
64
+ }
65
+
66
+ closeTerminal(id: number): Promise<number>;
67
+ closeTerminal(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<any, any>>;
68
+ closeTerminal(id: number, options: Options): Promise<number>;
69
+ closeTerminal(id: number, options?: Options) {
70
+ return super
71
+ .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
72
+ .then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
73
+ }
74
+ }
75
+ export { TerminalsActiveService };
@@ -0,0 +1,78 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { ApiTerminal } from '../interfaces/index.js';
3
+ import { Service, Options, RequirementsOf } from './index.js';
4
+
5
+ import { Terminal } from '../models/terminal.model.js';
6
+
7
+ type RequiredProps = 'name' | 'timezone';
8
+
9
+ class TerminalsService extends Service {
10
+ private apiPath = '/terminals';
11
+
12
+ create(data: RequirementsOf<ApiTerminal, RequiredProps>): Promise<Terminal>;
13
+ create(
14
+ data: RequirementsOf<ApiTerminal, RequiredProps>,
15
+ options: { rawResponse: true } & Options
16
+ ): Promise<AxiosResponse<ApiTerminal, any>>;
17
+ create(data: RequirementsOf<ApiTerminal, RequiredProps>, options: Options): Promise<Terminal>;
18
+ create(data: RequirementsOf<ApiTerminal, RequiredProps>, options?: Options) {
19
+ return super
20
+ .fetch<ApiTerminal>({ url: this.apiPath, data, method: 'POST' })
21
+ .then((res) => Promise.resolve(options?.rawResponse ? res : new Terminal(res.data)));
22
+ }
23
+
24
+ get(id: number): Promise<Terminal>;
25
+ get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiTerminal, any>>;
26
+ get(id: number, options: Options): Promise<Terminal>;
27
+ get(id: number, options?: Options) {
28
+ return super
29
+ .fetch<ApiTerminal>({ url: `${this.apiPath}/${id}` }, options)
30
+ .then((res) => Promise.resolve(options?.rawResponse ? res : new Terminal(res.data)));
31
+ }
32
+
33
+ update(id: number, data: Partial<ApiTerminal>): Promise<Terminal>;
34
+ update(
35
+ id: number,
36
+ data: Partial<ApiTerminal>,
37
+ options: { rawResponse: true } & Options
38
+ ): Promise<AxiosResponse<ApiTerminal, any>>;
39
+ update(id: number, data: Partial<ApiTerminal>, options: Options): Promise<Terminal>;
40
+ update(id: number, data: Partial<ApiTerminal>, options?: Options) {
41
+ return super
42
+ .fetch<ApiTerminal>({
43
+ url: `${this.apiPath}/${id}`,
44
+ data,
45
+ method: 'POST',
46
+ })
47
+ .then((res) => Promise.resolve(options?.rawResponse ? res : new Terminal(res.data)));
48
+ }
49
+
50
+ closeTerminal(id: number): Promise<number>;
51
+ closeTerminal(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<number, any>>;
52
+ closeTerminal(id: number, options: Options): Promise<number>;
53
+ closeTerminal(id: number, options?: Options) {
54
+ return super
55
+ .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
56
+ .then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
57
+ }
58
+
59
+ async *list(options?: Options) {
60
+ for await (const res of super.iterator<ApiTerminal>({ url: this.apiPath }, options)) {
61
+ yield new Terminal(res);
62
+ }
63
+ }
64
+
65
+ listAll(options?: Options): Promise<Terminal[]>;
66
+ async listAll(options?: Options) {
67
+ const users = [] as Terminal[];
68
+ for await (const user of this.list(options)) {
69
+ users.push(user);
70
+ }
71
+ return users;
72
+ }
73
+
74
+ listByPage(options?: Options) {
75
+ return super.iterator<ApiTerminal>({ url: this.apiPath }, options).byPage();
76
+ }
77
+ }
78
+ export { TerminalsService };
@@ -0,0 +1,125 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { ApiUserBreak, ApiUserClockedIn, ApiUserClockedOut, ApiTerminalLocation } from '../interfaces/index.js';
3
+ import { Service, Options, RequirementsOf } from './index.js';
4
+
5
+ import { UserClockedIn, UserClockedOut } from '../models/index.js';
6
+
7
+ interface UserClockIn {
8
+ method: string;
9
+ shift: number;
10
+ terminal: number;
11
+ user: number;
12
+ photo?: string;
13
+ location: ApiTerminalLocation;
14
+ }
15
+
16
+ interface UserClockOut extends Omit<UserClockIn, 'user' | 'shift'> {}
17
+
18
+ interface UserBreak {
19
+ method: string;
20
+ action: string;
21
+ terminal: number;
22
+ photo?: string;
23
+ location: ApiTerminalLocation;
24
+ }
25
+
26
+ class UserBreak {
27
+ public start_time: number;
28
+ public start_location: ApiTerminalLocation;
29
+ public end_time: number | null;
30
+ public end_location: ApiTerminalLocation | null;
31
+ constructor(apiUserBreak: ApiUserBreak) {
32
+ this.start_time = apiUserBreak.start_time;
33
+ this.start_location = apiUserBreak.start_location;
34
+ this.end_time = apiUserBreak.end_time ?? null;
35
+ this.end_location = apiUserBreak.end_location ?? null;
36
+ }
37
+ }
38
+
39
+ type RequiredPropsClockIn = 'method';
40
+ type RequiredPropsBreak = 'method' | 'action';
41
+
42
+ class UsersClockInService extends Service {
43
+ private apiPath = '/users_clocked_in';
44
+
45
+ getClockedInUser(id: number): Promise<UserClockedIn>;
46
+ getClockedInUser(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiUserClockedIn, any>>;
47
+ getClockedInUser(id: number, options: Options): Promise<UserClockedIn>;
48
+ getClockedInUser(id: number, options?: Options) {
49
+ return super
50
+ .fetch<ApiUserClockedIn>({ url: `${this.apiPath}/${id}` }, options)
51
+ .then((res) => Promise.resolve(options?.rawResponse ? res : new UserClockedIn(res.data)));
52
+ }
53
+
54
+ async *list(options?: Options) {
55
+ for await (const res of super.iterator<ApiUserClockedIn>({ url: this.apiPath }, options)) {
56
+ yield new UserClockedIn(res);
57
+ }
58
+ }
59
+
60
+ listAll(options?: Options): Promise<UserClockedIn[]>;
61
+ async listAll(options?: Options) {
62
+ const users = [] as UserClockedIn[];
63
+ for await (const user of this.list(options)) {
64
+ users.push(user);
65
+ }
66
+ return users;
67
+ }
68
+
69
+ listByPage(options?: Options) {
70
+ return super.iterator<ApiUserClockedIn>({ url: this.apiPath }, options).byPage();
71
+ }
72
+
73
+ clockIn(data: RequirementsOf<UserClockIn, RequiredPropsClockIn>): Promise<UserClockedIn>;
74
+ clockIn(
75
+ data: RequirementsOf<UserClockIn, RequiredPropsClockIn>,
76
+ options: { rawResponse: true } & Options
77
+ ): Promise<AxiosResponse<ApiUserClockedIn, any>>;
78
+ clockIn(data: RequirementsOf<UserClockIn, RequiredPropsClockIn>, options: Options): Promise<UserClockedIn>;
79
+ clockIn(data: RequirementsOf<UserClockIn, RequiredPropsClockIn>, options?: Options) {
80
+ return super
81
+ .fetch<ApiUserClockedIn>({ url: this.apiPath, data, method: 'POST' })
82
+ .then((res) => Promise.resolve(options?.rawResponse ? res : new UserClockedIn(res.data)));
83
+ }
84
+
85
+ clockOut(id: number, data: UserClockOut): Promise<UserClockedOut>;
86
+ clockOut(
87
+ id: number,
88
+ data: UserClockOut,
89
+ options: { rawResponse: true } & Options
90
+ ): Promise<AxiosResponse<ApiUserClockedOut, any>>;
91
+ clockOut(id: number, data: UserClockOut, options: Options): Promise<UserClockedOut>;
92
+ clockOut(id: number, data: UserClockOut, options?: Options) {
93
+ return super
94
+ .fetch<ApiUserClockedOut>({ url: `${this.apiPath}/${id}`, data, method: 'DELETE' })
95
+ .then((res) => Promise.resolve(options?.rawResponse ? res : new UserClockedOut(res.data)));
96
+ }
97
+
98
+ startBreak(id: number, data: RequirementsOf<UserBreak, RequiredPropsBreak>): Promise<UserBreak>;
99
+ startBreak(
100
+ id: number,
101
+ data: RequirementsOf<UserBreak, RequiredPropsBreak>,
102
+ options: { rawResponse: true } & Options
103
+ ): Promise<AxiosResponse<ApiUserBreak, any>>;
104
+ startBreak(id: number, data: RequirementsOf<UserBreak, RequiredPropsBreak>, options: Options): Promise<UserBreak>;
105
+ startBreak(id: number, data: RequirementsOf<UserBreak, RequiredPropsBreak>, options?: Options) {
106
+ return super
107
+ .fetch<ApiUserBreak>({ url: `${this.apiPath}/${id}`, data, method: 'POST' })
108
+ .then((res) => Promise.resolve(options?.rawResponse ? res : new UserBreak(res.data)));
109
+ }
110
+
111
+ endBreak(id: number, data: RequirementsOf<UserBreak, RequiredPropsBreak>): Promise<UserBreak>;
112
+ endBreak(
113
+ id: number,
114
+ data: RequirementsOf<UserBreak, RequiredPropsBreak>,
115
+ options: { rawResponse: true } & Options
116
+ ): Promise<AxiosResponse<ApiUserBreak, any>>;
117
+ endBreak(id: number, data: RequirementsOf<UserBreak, RequiredPropsBreak>, options: Options): Promise<UserBreak>;
118
+ endBreak(id: number, data: RequirementsOf<UserBreak, RequiredPropsBreak>, options?: Options) {
119
+ return super
120
+ .fetch<ApiUserBreak>({ url: `${this.apiPath}/${id}`, data, method: 'POST' })
121
+ .then((res) => Promise.resolve(options?.rawResponse ? res : new UserBreak(res.data)));
122
+ }
123
+ }
124
+
125
+ export { UsersClockInService };
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const Version = { version: '1.0.48' };
1
+ export const Version = { version: '1.0.51' };