rotacloud 1.0.41 → 1.0.44

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 (94) hide show
  1. package/dist/cjs/interfaces/index.d.ts +2 -0
  2. package/dist/cjs/interfaces/index.js +2 -0
  3. package/dist/cjs/interfaces/leave-date.interface.d.ts +1 -1
  4. package/dist/cjs/interfaces/leave.interface.d.ts +1 -1
  5. package/dist/cjs/interfaces/query-params/index.d.ts +2 -0
  6. package/dist/cjs/interfaces/query-params/index.js +2 -0
  7. package/dist/cjs/interfaces/query-params/toil-accruals-query-params.interface.d.ts +4 -0
  8. package/dist/cjs/interfaces/query-params/toil-accruals-query-params.interface.js +2 -0
  9. package/dist/cjs/interfaces/query-params/toil-allowance-query-params.interface.d.ts +3 -0
  10. package/dist/cjs/interfaces/query-params/toil-allowance-query-params.interface.js +2 -0
  11. package/dist/cjs/interfaces/toil-accrual.interface.d.ts +14 -0
  12. package/dist/cjs/interfaces/toil-accrual.interface.js +2 -0
  13. package/dist/cjs/interfaces/toil-allowance.interface.d.ts +7 -0
  14. package/dist/cjs/interfaces/toil-allowance.interface.js +2 -0
  15. package/dist/cjs/models/SDKError.model.d.ts +1 -1
  16. package/dist/cjs/models/SDKError.model.js +1 -1
  17. package/dist/cjs/models/index.d.ts +2 -0
  18. package/dist/cjs/models/index.js +2 -0
  19. package/dist/cjs/models/leave.model.d.ts +1 -1
  20. package/dist/cjs/models/toil-accrual.model.d.ts +16 -0
  21. package/dist/cjs/models/toil-accrual.model.js +20 -0
  22. package/dist/cjs/models/toil-allowance.model.d.ts +9 -0
  23. package/dist/cjs/models/toil-allowance.model.js +13 -0
  24. package/dist/cjs/rotacloud.d.ts +3 -1
  25. package/dist/cjs/rotacloud.js +2 -0
  26. package/dist/cjs/services/index.d.ts +2 -0
  27. package/dist/cjs/services/index.js +2 -0
  28. package/dist/cjs/services/leave-request.service.js +5 -1
  29. package/dist/cjs/services/leave.service.js +1 -1
  30. package/dist/cjs/services/service.d.ts +1 -0
  31. package/dist/cjs/services/service.js +1 -1
  32. package/dist/cjs/services/toil-accruals.service.d.ts +28 -0
  33. package/dist/cjs/services/toil-accruals.service.js +99 -0
  34. package/dist/cjs/services/toil-allowance.service.d.ts +10 -0
  35. package/dist/cjs/services/toil-allowance.service.js +84 -0
  36. package/dist/cjs/version.js +1 -1
  37. package/dist/mjs/interfaces/index.d.ts +2 -0
  38. package/dist/mjs/interfaces/index.js +2 -0
  39. package/dist/mjs/interfaces/leave-date.interface.d.ts +1 -1
  40. package/dist/mjs/interfaces/leave.interface.d.ts +1 -1
  41. package/dist/mjs/interfaces/query-params/index.d.ts +2 -0
  42. package/dist/mjs/interfaces/query-params/index.js +2 -0
  43. package/dist/mjs/interfaces/query-params/toil-accruals-query-params.interface.d.ts +4 -0
  44. package/dist/mjs/interfaces/query-params/toil-accruals-query-params.interface.js +1 -0
  45. package/dist/mjs/interfaces/query-params/toil-allowance-query-params.interface.d.ts +3 -0
  46. package/dist/mjs/interfaces/query-params/toil-allowance-query-params.interface.js +1 -0
  47. package/dist/mjs/interfaces/toil-accrual.interface.d.ts +14 -0
  48. package/dist/mjs/interfaces/toil-accrual.interface.js +1 -0
  49. package/dist/mjs/interfaces/toil-allowance.interface.d.ts +7 -0
  50. package/dist/mjs/interfaces/toil-allowance.interface.js +1 -0
  51. package/dist/mjs/models/SDKError.model.d.ts +1 -1
  52. package/dist/mjs/models/SDKError.model.js +1 -1
  53. package/dist/mjs/models/index.d.ts +2 -0
  54. package/dist/mjs/models/index.js +2 -0
  55. package/dist/mjs/models/leave.model.d.ts +1 -1
  56. package/dist/mjs/models/toil-accrual.model.d.ts +16 -0
  57. package/dist/mjs/models/toil-accrual.model.js +16 -0
  58. package/dist/mjs/models/toil-allowance.model.d.ts +9 -0
  59. package/dist/mjs/models/toil-allowance.model.js +9 -0
  60. package/dist/mjs/rotacloud.d.ts +3 -1
  61. package/dist/mjs/rotacloud.js +3 -1
  62. package/dist/mjs/services/index.d.ts +2 -0
  63. package/dist/mjs/services/index.js +2 -0
  64. package/dist/mjs/services/leave-request.service.js +5 -1
  65. package/dist/mjs/services/leave.service.js +1 -1
  66. package/dist/mjs/services/service.d.ts +1 -0
  67. package/dist/mjs/services/service.js +1 -0
  68. package/dist/mjs/services/toil-accruals.service.d.ts +28 -0
  69. package/dist/mjs/services/toil-accruals.service.js +38 -0
  70. package/dist/mjs/services/toil-allowance.service.d.ts +10 -0
  71. package/dist/mjs/services/toil-allowance.service.js +23 -0
  72. package/dist/mjs/version.js +1 -1
  73. package/package.json +1 -1
  74. package/src/interfaces/index.ts +2 -0
  75. package/src/interfaces/leave-date.interface.ts +1 -1
  76. package/src/interfaces/leave.interface.ts +1 -1
  77. package/src/interfaces/query-params/index.ts +2 -0
  78. package/src/interfaces/query-params/toil-accruals-query-params.interface.ts +4 -0
  79. package/src/interfaces/query-params/toil-allowance-query-params.interface.ts +3 -0
  80. package/src/interfaces/toil-accrual.interface.ts +14 -0
  81. package/src/interfaces/toil-allowance.interface.ts +7 -0
  82. package/src/models/SDKError.model.ts +1 -1
  83. package/src/models/index.ts +2 -0
  84. package/src/models/leave.model.ts +1 -1
  85. package/src/models/toil-accrual.model.ts +30 -0
  86. package/src/models/toil-allowance.model.ts +16 -0
  87. package/src/rotacloud.ts +4 -0
  88. package/src/services/index.ts +2 -0
  89. package/src/services/leave-request.service.ts +8 -1
  90. package/src/services/leave.service.ts +1 -1
  91. package/src/services/service.ts +2 -0
  92. package/src/services/toil-accruals.service.ts +59 -0
  93. package/src/services/toil-allowance.service.ts +29 -0
  94. package/src/version.ts +1 -1
@@ -0,0 +1,7 @@
1
+ export interface ApiToilAllowance {
2
+ user: number;
3
+ accrued_hours: number;
4
+ remaining_hours: number;
5
+ used_hours: number;
6
+ has_toil_records: boolean;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -4,8 +4,8 @@ export interface SDKErrorConfig {
4
4
  data?: unknown;
5
5
  }
6
6
  export declare class SDKError extends Error {
7
+ name: string;
7
8
  readonly code?: number;
8
9
  readonly data?: unknown;
9
- name: string;
10
10
  constructor(errorConfig: SDKErrorConfig);
11
11
  }
@@ -1,7 +1,7 @@
1
1
  export class SDKError extends Error {
2
2
  constructor(errorConfig) {
3
3
  super(errorConfig.message);
4
- this.name = this.constructor.name;
4
+ this.name = 'SDKError';
5
5
  Error.captureStackTrace?.(this, SDKError);
6
6
  // optional chaining needed as is v8 specific https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#static_methods
7
7
  this.data = errorConfig.data;
@@ -26,4 +26,6 @@ export * from './role.model.js';
26
26
  export * from './settings.model.js';
27
27
  export * from './shift.model.js';
28
28
  export * from './terminal.model.js';
29
+ export * from './toil-accrual.model.js';
30
+ export * from './toil-allowance.model.js';
29
31
  export * from './user.model.js';
@@ -26,4 +26,6 @@ export * from './role.model.js';
26
26
  export * from './settings.model.js';
27
27
  export * from './shift.model.js';
28
28
  export * from './terminal.model.js';
29
+ export * from './toil-accrual.model.js';
30
+ export * from './toil-allowance.model.js';
29
31
  export * from './user.model.js';
@@ -18,7 +18,7 @@ export declare class Leave {
18
18
  start_am_pm: string;
19
19
  end_am_pm: string;
20
20
  hours: {
21
- [key: string]: number;
21
+ [key: string]: number | null;
22
22
  };
23
23
  hours_method: string;
24
24
  hours_set: boolean;
@@ -0,0 +1,16 @@
1
+ import { ApiToilAccrual } from '../interfaces/toil-accrual.interface';
2
+ export declare class ToilAccrual {
3
+ comments: string;
4
+ created_at: number;
5
+ created_by: number | null;
6
+ date: string;
7
+ deleted: boolean;
8
+ deleted_at: string | null;
9
+ deleted_by: number | null;
10
+ duration_hours: number;
11
+ id: number;
12
+ leave_year: number;
13
+ location_id: number | null;
14
+ user_id: number;
15
+ constructor(accrual: ApiToilAccrual);
16
+ }
@@ -0,0 +1,16 @@
1
+ export class ToilAccrual {
2
+ constructor(accrual) {
3
+ this.comments = accrual.comments;
4
+ this.created_at = accrual.created_at;
5
+ this.created_by = accrual.created_by;
6
+ this.date = accrual.date;
7
+ this.deleted = accrual.deleted;
8
+ this.deleted_at = accrual.deleted_at;
9
+ this.deleted_by = accrual.deleted_by;
10
+ this.duration_hours = accrual.duration_hours;
11
+ this.id = accrual.id;
12
+ this.leave_year = accrual.leave_year;
13
+ this.location_id = accrual.location_id;
14
+ this.user_id = accrual.user_id;
15
+ }
16
+ }
@@ -0,0 +1,9 @@
1
+ import { ApiToilAllowance } from '../interfaces/toil-allowance.interface';
2
+ export declare class ToilAllowance {
3
+ user: number;
4
+ accrued_hours: number;
5
+ remaining_hours: number;
6
+ used_hours: number;
7
+ has_toil_records: boolean;
8
+ constructor(allowance: ApiToilAllowance);
9
+ }
@@ -0,0 +1,9 @@
1
+ export class ToilAllowance {
2
+ constructor(allowance) {
3
+ this.user = allowance.user;
4
+ this.accrued_hours = allowance.accrued_hours;
5
+ this.remaining_hours = allowance.accrued_hours;
6
+ this.used_hours = allowance.used_hours;
7
+ this.has_toil_records = allowance.has_toil_records;
8
+ }
9
+ }
@@ -1,4 +1,4 @@
1
- import { AccountsService, AttendanceService, AuthService, AvailabilityService, DailyBudgetsService, DailyRevenueService, DaysOffService, GroupsService, LeaveEmbargoesService, LeaveRequestService, LeaveService, LocationsService, RolesService, SettingsService, ShiftsService, UsersService } from './services/index.js';
1
+ import { AccountsService, AttendanceService, AuthService, AvailabilityService, DailyBudgetsService, DailyRevenueService, DaysOffService, GroupsService, LeaveEmbargoesService, LeaveRequestService, LeaveService, LocationsService, RolesService, SettingsService, ShiftsService, ToilAccrualsService, ToilAllowanceService, UsersService } from './services/index.js';
2
2
  import { SDKConfig } from './interfaces/index.js';
3
3
  import { DayNotesService } from './services/day-notes.service.js';
4
4
  export declare class RotaCloud {
@@ -20,6 +20,8 @@ export declare class RotaCloud {
20
20
  roles: RolesService;
21
21
  settings: SettingsService;
22
22
  shifts: ShiftsService;
23
+ toilAccruals: ToilAccrualsService;
24
+ toilAllowance: ToilAllowanceService;
23
25
  users: UsersService;
24
26
  constructor(config: SDKConfig);
25
27
  get config(): SDKConfig;
@@ -1,4 +1,4 @@
1
- import { AccountsService, AttendanceService, AuthService, AvailabilityService, DailyBudgetsService, DailyRevenueService, DaysOffService, GroupsService, LeaveEmbargoesService, LeaveRequestService, LeaveService, LocationsService, RetryStrategy, RolesService, SettingsService, ShiftsService, UsersService, } from './services/index.js';
1
+ import { AccountsService, AttendanceService, AuthService, AvailabilityService, DailyBudgetsService, DailyRevenueService, DaysOffService, GroupsService, LeaveEmbargoesService, LeaveRequestService, LeaveService, LocationsService, RetryStrategy, RolesService, SettingsService, ShiftsService, ToilAccrualsService, ToilAllowanceService, UsersService, } from './services/index.js';
2
2
  import { DayNotesService } from './services/day-notes.service.js';
3
3
  const DEFAULT_CONFIG = {
4
4
  baseUri: 'https://api.rotacloud.com/v1',
@@ -23,6 +23,8 @@ export class RotaCloud {
23
23
  this.roles = new RolesService();
24
24
  this.settings = new SettingsService();
25
25
  this.shifts = new ShiftsService();
26
+ this.toilAccruals = new ToilAccrualsService();
27
+ this.toilAllowance = new ToilAllowanceService();
26
28
  this.users = new UsersService();
27
29
  this.config = {
28
30
  ...DEFAULT_CONFIG,
@@ -14,4 +14,6 @@ export * from './locations.service.js';
14
14
  export * from './roles.service.js';
15
15
  export * from './settings.service.js';
16
16
  export * from './shifts.service.js';
17
+ export * from './toil-accruals.service.js';
18
+ export * from './toil-allowance.service.js';
17
19
  export * from './users.service.js';
@@ -14,4 +14,6 @@ export * from './locations.service.js';
14
14
  export * from './roles.service.js';
15
15
  export * from './settings.service.js';
16
16
  export * from './shifts.service.js';
17
+ export * from './toil-accruals.service.js';
18
+ export * from './toil-allowance.service.js';
17
19
  export * from './users.service.js';
@@ -7,7 +7,11 @@ export class LeaveRequestService extends Service {
7
7
  }
8
8
  create(data, options) {
9
9
  return super
10
- .fetch({ url: this.apiPath, data, method: 'POST' })
10
+ .fetch({
11
+ url: this.apiPath,
12
+ data,
13
+ method: 'POST',
14
+ }, options)
11
15
  .then((res) => Promise.resolve(options?.rawResponse ? res : new LeaveRequest(res.data)));
12
16
  }
13
17
  get(id, options) {
@@ -8,7 +8,7 @@ export class LeaveService extends Service {
8
8
  }
9
9
  create(data, options) {
10
10
  return super
11
- .fetch({ url: this.apiPath, data, method: 'POST' })
11
+ .fetch({ url: this.apiPath, data, method: 'POST' }, options)
12
12
  .then((res) => Promise.resolve(options?.rawResponse ? res : [...res.data.map((leave) => new Leave(leave))]));
13
13
  }
14
14
  get(id, options) {
@@ -22,6 +22,7 @@ export interface Options {
22
22
  expand?: string[];
23
23
  fields?: string[];
24
24
  limit?: number;
25
+ dryRun?: boolean;
25
26
  }
26
27
  export declare abstract class Service<ApiResponse = any> {
27
28
  protected client: AxiosInstance;
@@ -98,6 +98,7 @@ export class Service {
98
98
  expand: options?.expand,
99
99
  fields: options?.fields,
100
100
  limit: options?.limit,
101
+ dry_run: options?.dryRun,
101
102
  ...httpOptions?.params,
102
103
  },
103
104
  paramsSerializer: this.buildQueryStr,
@@ -0,0 +1,28 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { Options, RequirementsOf, Service } from './service';
3
+ import { ToilAccrualsQueryParams } from '../interfaces/query-params/toil-accruals-query-params.interface';
4
+ import { ToilAccrual } from '../models/toil-accrual.model';
5
+ import { ApiToilAccrual } from '../interfaces/toil-accrual.interface';
6
+ declare type RequiredProps = 'duration_hours' | 'date' | 'leave_year' | 'user_id';
7
+ export declare class ToilAccrualsService extends Service {
8
+ private apiPath;
9
+ create(data: RequirementsOf<ApiToilAccrual, RequiredProps>): Promise<ToilAccrual>;
10
+ create(data: RequirementsOf<ApiToilAccrual, RequiredProps>, options: {
11
+ rawResponse: true;
12
+ } & Options): Promise<AxiosResponse<ApiToilAccrual, any>>;
13
+ create(data: RequirementsOf<ApiToilAccrual, RequiredProps>, options: Options): Promise<ToilAccrual>;
14
+ get(id: number): Promise<ToilAccrual>;
15
+ get(id: number, options: {
16
+ rawResponse: true;
17
+ } & Options): Promise<AxiosResponse<ToilAccrual, any>>;
18
+ get(id: number, options: Options): Promise<ToilAccrual>;
19
+ list(query: ToilAccrualsQueryParams, options?: Options): AsyncGenerator<ToilAccrual, void, unknown>;
20
+ listAll(query: ToilAccrualsQueryParams, options?: Options): Promise<ToilAccrual[]>;
21
+ listByPage(query: ToilAccrualsQueryParams, options?: Options): AsyncGenerator<AxiosResponse<ApiToilAccrual[], any>, any, unknown>;
22
+ delete(id: number): Promise<number>;
23
+ delete(id: number, options: {
24
+ rawResponse: true;
25
+ } & Options): Promise<AxiosResponse<any, any>>;
26
+ delete(id: number, options: Options): Promise<number>;
27
+ }
28
+ export {};
@@ -0,0 +1,38 @@
1
+ import { Service } from './service';
2
+ import { ToilAccrual } from '../models/toil-accrual.model';
3
+ export class ToilAccrualsService extends Service {
4
+ constructor() {
5
+ super(...arguments);
6
+ this.apiPath = '/toil_accruals';
7
+ }
8
+ create(data, options) {
9
+ return super
10
+ .fetch({ url: this.apiPath, data, method: 'POST' })
11
+ .then((res) => Promise.resolve(options?.rawResponse ? res : new ToilAccrual(res.data)));
12
+ }
13
+ get(id, options) {
14
+ return super
15
+ .fetch({ url: `${this.apiPath}/${id}` }, options)
16
+ .then((res) => Promise.resolve(options?.rawResponse ? res : new ToilAccrual(res.data)));
17
+ }
18
+ async *list(query, options) {
19
+ for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
20
+ yield new ToilAccrual(res);
21
+ }
22
+ }
23
+ async listAll(query, options) {
24
+ const toilAccruals = [];
25
+ for await (const accrual of this.list(query, options)) {
26
+ toilAccruals.push(accrual);
27
+ }
28
+ return toilAccruals;
29
+ }
30
+ listByPage(query, options) {
31
+ return super.iterator({ url: this.apiPath, params: query }, options).byPage();
32
+ }
33
+ delete(id, options) {
34
+ return super
35
+ .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
36
+ .then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
37
+ }
38
+ }
@@ -0,0 +1,10 @@
1
+ import { Options, Service } from './service';
2
+ import { ToilAllowanceQueryParams } from '../interfaces/query-params/toil-allowance-query-params.interface';
3
+ import { ApiToilAllowance } from '../interfaces/toil-allowance.interface';
4
+ import { ToilAllowance } from '../models/toil-allowance.model';
5
+ export declare class ToilAllowanceService extends Service {
6
+ private apiPath;
7
+ list(year: number, query: ToilAllowanceQueryParams, options?: Options): AsyncGenerator<ToilAllowance, void, unknown>;
8
+ listAll(year: number, query: ToilAllowanceQueryParams, options?: Options): Promise<ToilAllowance[]>;
9
+ listByPage(year: number, query: ToilAllowanceQueryParams, options?: Options): AsyncGenerator<import("axios").AxiosResponse<ApiToilAllowance[][], any>, any, unknown>;
10
+ }
@@ -0,0 +1,23 @@
1
+ import { Service } from './service';
2
+ import { ToilAllowance } from '../models/toil-allowance.model';
3
+ export class ToilAllowanceService extends Service {
4
+ constructor() {
5
+ super(...arguments);
6
+ this.apiPath = '/toil_allowance';
7
+ }
8
+ async *list(year, query, options) {
9
+ for await (const res of super.iterator({ url: `${this.apiPath}/${year}`, params: query }, options)) {
10
+ yield new ToilAllowance(res);
11
+ }
12
+ }
13
+ async listAll(year, query, options) {
14
+ const toilAllowances = [];
15
+ for await (const allowance of this.list(year, query, options)) {
16
+ toilAllowances.push(allowance);
17
+ }
18
+ return toilAllowances;
19
+ }
20
+ listByPage(year, query, options) {
21
+ return super.iterator({ url: `${this.apiPath}/${year}`, params: query }, options).byPage();
22
+ }
23
+ }
@@ -1 +1 @@
1
- export const Version = { version: '1.0.41' };
1
+ export const Version = { version: '1.0.44' };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rotacloud",
3
- "version": "1.0.41",
3
+ "version": "1.0.44",
4
4
  "description": "The RotaCloud SDK for the RotaCloud API",
5
5
  "engines": {
6
6
  "node": ">=14.17.0"
@@ -28,4 +28,6 @@ export * from './role.interface.js';
28
28
  export * from './sdk-config.interface.js';
29
29
  export * from './settings.interface.js';
30
30
  export * from './shift.interface.js';
31
+ export * from './toil-accrual.interface.js';
32
+ export * from './toil-allowance.interface.js';
31
33
  export * from './user.interface.js';
@@ -2,7 +2,7 @@ export interface ApiLeaveDate {
2
2
  date: string;
3
3
  year: string;
4
4
  days: number;
5
- hours: number;
5
+ hours: number | null;
6
6
  day_off: boolean;
7
7
  id?: number;
8
8
  }
@@ -16,7 +16,7 @@ export interface ApiLeave {
16
16
  start_am_pm: string;
17
17
  end_date: string;
18
18
  end_am_pm: string;
19
- hours: { [key: string]: number };
19
+ hours: { [key: string]: number | null };
20
20
  hours_method: string;
21
21
  hours_set: boolean;
22
22
  dates: ApiLeaveDate[];
@@ -21,5 +21,7 @@ export * from './settings-query-params.interface.js';
21
21
  export * from './shifts-query-params.interface.js';
22
22
  export * from './swap-requests-query-params.interface.js';
23
23
  export * from './terminals-query-params.interface.js';
24
+ export * from './toil-accruals-query-params.interface.js';
25
+ export * from './toil-allowance-query-params.interface.js';
24
26
  export * from './unavailability-requests-query-params.interface.js';
25
27
  export * from './users-query-params.interface.js';
@@ -0,0 +1,4 @@
1
+ export interface ToilAccrualsQueryParams {
2
+ year: number;
3
+ users?: number[];
4
+ }
@@ -0,0 +1,3 @@
1
+ export interface ToilAllowanceQueryParams {
2
+ users?: number[];
3
+ }
@@ -0,0 +1,14 @@
1
+ export interface ApiToilAccrual {
2
+ comments: string;
3
+ created_at: number;
4
+ created_by: number | null;
5
+ date: string;
6
+ deleted: boolean;
7
+ deleted_at: string | null;
8
+ deleted_by: number | null;
9
+ duration_hours: number;
10
+ id: number;
11
+ leave_year: number;
12
+ location_id: number | null;
13
+ user_id: number;
14
+ }
@@ -0,0 +1,7 @@
1
+ export interface ApiToilAllowance {
2
+ user: number;
3
+ accrued_hours: number;
4
+ remaining_hours: number;
5
+ used_hours: number;
6
+ has_toil_records: boolean;
7
+ }
@@ -4,9 +4,9 @@ export interface SDKErrorConfig {
4
4
  data?: unknown;
5
5
  }
6
6
  export class SDKError extends Error {
7
+ override name = 'SDKError';
7
8
  readonly code?: number;
8
9
  readonly data?: unknown;
9
- override name = this.constructor.name;
10
10
 
11
11
  constructor(errorConfig: SDKErrorConfig) {
12
12
  super(errorConfig.message);
@@ -26,4 +26,6 @@ export * from './role.model.js';
26
26
  export * from './settings.model.js';
27
27
  export * from './shift.model.js';
28
28
  export * from './terminal.model.js';
29
+ export * from './toil-accrual.model.js';
30
+ export * from './toil-allowance.model.js';
29
31
  export * from './user.model.js';
@@ -18,7 +18,7 @@ export class Leave {
18
18
  public admin: number;
19
19
  public start_am_pm: string;
20
20
  public end_am_pm: string;
21
- public hours: { [key: string]: number };
21
+ public hours: { [key: string]: number | null };
22
22
  public hours_method: string;
23
23
  public hours_set: boolean;
24
24
  public requested_at: number;
@@ -0,0 +1,30 @@
1
+ import { ApiToilAccrual } from '../interfaces/toil-accrual.interface';
2
+
3
+ export class ToilAccrual {
4
+ public comments: string;
5
+ public created_at: number;
6
+ public created_by: number | null;
7
+ public date: string;
8
+ public deleted: boolean;
9
+ public deleted_at: string | null;
10
+ public deleted_by: number | null;
11
+ public duration_hours: number;
12
+ public id: number;
13
+ public leave_year: number;
14
+ public location_id: number | null;
15
+ public user_id: number;
16
+ constructor(accrual: ApiToilAccrual) {
17
+ this.comments = accrual.comments;
18
+ this.created_at = accrual.created_at;
19
+ this.created_by = accrual.created_by;
20
+ this.date = accrual.date;
21
+ this.deleted = accrual.deleted;
22
+ this.deleted_at = accrual.deleted_at;
23
+ this.deleted_by = accrual.deleted_by;
24
+ this.duration_hours = accrual.duration_hours;
25
+ this.id = accrual.id;
26
+ this.leave_year = accrual.leave_year;
27
+ this.location_id = accrual.location_id;
28
+ this.user_id = accrual.user_id;
29
+ }
30
+ }
@@ -0,0 +1,16 @@
1
+ import { ApiToilAllowance } from '../interfaces/toil-allowance.interface';
2
+
3
+ export class ToilAllowance {
4
+ public user: number;
5
+ public accrued_hours: number;
6
+ public remaining_hours: number;
7
+ public used_hours: number;
8
+ public has_toil_records: boolean;
9
+ constructor(allowance: ApiToilAllowance) {
10
+ this.user = allowance.user;
11
+ this.accrued_hours = allowance.accrued_hours;
12
+ this.remaining_hours = allowance.accrued_hours;
13
+ this.used_hours = allowance.used_hours;
14
+ this.has_toil_records = allowance.has_toil_records;
15
+ }
16
+ }
package/src/rotacloud.ts CHANGED
@@ -15,6 +15,8 @@ import {
15
15
  RolesService,
16
16
  SettingsService,
17
17
  ShiftsService,
18
+ ToilAccrualsService,
19
+ ToilAllowanceService,
18
20
  UsersService,
19
21
  } from './services/index.js';
20
22
  import { SDKConfig } from './interfaces/index.js';
@@ -45,6 +47,8 @@ export class RotaCloud {
45
47
  public roles = new RolesService();
46
48
  public settings = new SettingsService();
47
49
  public shifts = new ShiftsService();
50
+ public toilAccruals = new ToilAccrualsService();
51
+ public toilAllowance = new ToilAllowanceService();
48
52
  public users = new UsersService();
49
53
 
50
54
  constructor(config: SDKConfig) {
@@ -14,4 +14,6 @@ export * from './locations.service.js';
14
14
  export * from './roles.service.js';
15
15
  export * from './settings.service.js';
16
16
  export * from './shifts.service.js';
17
+ export * from './toil-accruals.service.js';
18
+ export * from './toil-allowance.service.js';
17
19
  export * from './users.service.js';
@@ -19,7 +19,14 @@ export class LeaveRequestService extends Service {
19
19
  create(data: RequirementsOf<ApiLeaveRequest, RequiredProps>, options: Options): Promise<LeaveRequest>;
20
20
  create(data: RequirementsOf<ApiLeaveRequest, RequiredProps>, options?: Options) {
21
21
  return super
22
- .fetch<ApiLeaveRequest>({ url: this.apiPath, data, method: 'POST' })
22
+ .fetch<ApiLeaveRequest>(
23
+ {
24
+ url: this.apiPath,
25
+ data,
26
+ method: 'POST',
27
+ },
28
+ options
29
+ )
23
30
  .then((res) => Promise.resolve(options?.rawResponse ? res : new LeaveRequest(res.data)));
24
31
  }
25
32
 
@@ -21,7 +21,7 @@ export class LeaveService extends Service {
21
21
  create(data: RequirementsOf<ApiLeave, RequiredProps>, options: Options): Promise<Leave[]>;
22
22
  create(data: RequirementsOf<ApiLeave, RequiredProps>, options?: Options) {
23
23
  return super
24
- .fetch<ApiLeave[]>({ url: this.apiPath, data, method: 'POST' })
24
+ .fetch<ApiLeave[]>({ url: this.apiPath, data, method: 'POST' }, options)
25
25
  .then((res) => Promise.resolve(options?.rawResponse ? res : [...res.data.map((leave) => new Leave(leave))]));
26
26
  }
27
27
 
@@ -47,6 +47,7 @@ export interface Options {
47
47
  expand?: string[];
48
48
  fields?: string[];
49
49
  limit?: number;
50
+ dryRun?: boolean;
50
51
  }
51
52
 
52
53
  interface PagingObject {
@@ -145,6 +146,7 @@ export abstract class Service<ApiResponse = any> {
145
146
  expand: options?.expand,
146
147
  fields: options?.fields,
147
148
  limit: options?.limit,
149
+ dry_run: options?.dryRun,
148
150
  ...httpOptions?.params,
149
151
  },
150
152
  paramsSerializer: this.buildQueryStr,
@@ -0,0 +1,59 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { Options, RequirementsOf, Service } from './service';
3
+ import { ToilAccrualsQueryParams } from '../interfaces/query-params/toil-accruals-query-params.interface';
4
+ import { ToilAccrual } from '../models/toil-accrual.model';
5
+ import { ApiToilAccrual } from '../interfaces/toil-accrual.interface';
6
+
7
+ type RequiredProps = 'duration_hours' | 'date' | 'leave_year' | 'user_id';
8
+
9
+ export class ToilAccrualsService extends Service {
10
+ private apiPath = '/toil_accruals';
11
+
12
+ create(data: RequirementsOf<ApiToilAccrual, RequiredProps>): Promise<ToilAccrual>;
13
+ create(
14
+ data: RequirementsOf<ApiToilAccrual, RequiredProps>,
15
+ options: { rawResponse: true } & Options
16
+ ): Promise<AxiosResponse<ApiToilAccrual, any>>;
17
+ create(data: RequirementsOf<ApiToilAccrual, RequiredProps>, options: Options): Promise<ToilAccrual>;
18
+ create(data: RequirementsOf<ApiToilAccrual, RequiredProps>, options?: Options) {
19
+ return super
20
+ .fetch<ToilAccrual>({ url: this.apiPath, data, method: 'POST' })
21
+ .then((res) => Promise.resolve(options?.rawResponse ? res : new ToilAccrual(res.data)));
22
+ }
23
+
24
+ get(id: number): Promise<ToilAccrual>;
25
+ get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ToilAccrual, any>>;
26
+ get(id: number, options: Options): Promise<ToilAccrual>;
27
+ get(id: number, options?: Options) {
28
+ return super
29
+ .fetch<ToilAccrual>({ url: `${this.apiPath}/${id}` }, options)
30
+ .then((res) => Promise.resolve(options?.rawResponse ? res : new ToilAccrual(res.data)));
31
+ }
32
+
33
+ async *list(query: ToilAccrualsQueryParams, options?: Options) {
34
+ for await (const res of super.iterator<ApiToilAccrual>({ url: this.apiPath, params: query }, options)) {
35
+ yield new ToilAccrual(res);
36
+ }
37
+ }
38
+
39
+ async listAll(query: ToilAccrualsQueryParams, options?: Options): Promise<ToilAccrual[]> {
40
+ const toilAccruals = [] as ToilAccrual[];
41
+ for await (const accrual of this.list(query, options)) {
42
+ toilAccruals.push(accrual);
43
+ }
44
+ return toilAccruals;
45
+ }
46
+
47
+ listByPage(query: ToilAccrualsQueryParams, options?: Options) {
48
+ return super.iterator<ApiToilAccrual>({ url: this.apiPath, params: query }, options).byPage();
49
+ }
50
+
51
+ delete(id: number): Promise<number>;
52
+ delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<any, any>>;
53
+ delete(id: number, options: Options): Promise<number>;
54
+ delete(id: number, options?: Options) {
55
+ return super
56
+ .fetch<ApiToilAccrual>({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
57
+ .then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
58
+ }
59
+ }
@@ -0,0 +1,29 @@
1
+ import { Options, Service } from './service';
2
+ import { ToilAllowanceQueryParams } from '../interfaces/query-params/toil-allowance-query-params.interface';
3
+ import { ApiToilAllowance } from '../interfaces/toil-allowance.interface';
4
+ import { ToilAllowance } from '../models/toil-allowance.model';
5
+
6
+ export class ToilAllowanceService extends Service {
7
+ private apiPath = '/toil_allowance';
8
+
9
+ async *list(year: number, query: ToilAllowanceQueryParams, options?: Options) {
10
+ for await (const res of super.iterator<ApiToilAllowance>(
11
+ { url: `${this.apiPath}/${year}`, params: query },
12
+ options
13
+ )) {
14
+ yield new ToilAllowance(res);
15
+ }
16
+ }
17
+
18
+ async listAll(year: number, query: ToilAllowanceQueryParams, options?: Options): Promise<ToilAllowance[]> {
19
+ const toilAllowances = [] as ToilAllowance[];
20
+ for await (const allowance of this.list(year, query, options)) {
21
+ toilAllowances.push(allowance);
22
+ }
23
+ return toilAllowances;
24
+ }
25
+
26
+ listByPage(year: number, query: ToilAllowanceQueryParams, options?: Options) {
27
+ return super.iterator<ApiToilAllowance[]>({ url: `${this.apiPath}/${year}`, params: query }, options).byPage();
28
+ }
29
+ }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const Version = { version: '1.0.41' };
1
+ export const Version = { version: '1.0.44' };