rotacloud 1.0.40 → 1.0.41

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 (77) hide show
  1. package/dist/cjs/models/SDKError.model.d.ts +11 -0
  2. package/dist/cjs/models/SDKError.model.js +15 -0
  3. package/dist/cjs/models/index.d.ts +1 -1
  4. package/dist/cjs/models/index.js +1 -1
  5. package/dist/cjs/services/accounts.service.js +3 -2
  6. package/dist/cjs/services/attendance.service.js +10 -5
  7. package/dist/cjs/services/auth.service.js +3 -2
  8. package/dist/cjs/services/availability.service.js +1 -2
  9. package/dist/cjs/services/daily-budgets.service.js +1 -2
  10. package/dist/cjs/services/daily-revenue.service.js +1 -2
  11. package/dist/cjs/services/day-notes.service.js +10 -5
  12. package/dist/cjs/services/days-off.service.js +2 -3
  13. package/dist/cjs/services/groups.service.js +10 -5
  14. package/dist/cjs/services/leave-embargoes.service.js +10 -5
  15. package/dist/cjs/services/leave-request.service.js +10 -5
  16. package/dist/cjs/services/leave.service.js +10 -5
  17. package/dist/cjs/services/locations.service.js +10 -5
  18. package/dist/cjs/services/roles.service.js +10 -5
  19. package/dist/cjs/services/service.d.ts +2 -0
  20. package/dist/cjs/services/service.js +23 -1
  21. package/dist/cjs/services/settings.service.js +3 -2
  22. package/dist/cjs/services/shifts.service.d.ts +3 -3
  23. package/dist/cjs/services/shifts.service.js +21 -9
  24. package/dist/cjs/services/users.service.js +10 -5
  25. package/dist/cjs/version.js +1 -1
  26. package/dist/mjs/models/SDKError.model.d.ts +11 -0
  27. package/dist/mjs/models/SDKError.model.js +10 -0
  28. package/dist/mjs/models/index.d.ts +1 -1
  29. package/dist/mjs/models/index.js +1 -1
  30. package/dist/mjs/services/accounts.service.js +3 -2
  31. package/dist/mjs/services/attendance.service.js +10 -5
  32. package/dist/mjs/services/auth.service.js +3 -2
  33. package/dist/mjs/services/availability.service.js +1 -2
  34. package/dist/mjs/services/daily-budgets.service.js +1 -2
  35. package/dist/mjs/services/daily-revenue.service.js +1 -2
  36. package/dist/mjs/services/day-notes.service.js +10 -5
  37. package/dist/mjs/services/days-off.service.js +2 -3
  38. package/dist/mjs/services/groups.service.js +10 -5
  39. package/dist/mjs/services/leave-embargoes.service.js +10 -5
  40. package/dist/mjs/services/leave-request.service.js +10 -5
  41. package/dist/mjs/services/leave.service.js +10 -5
  42. package/dist/mjs/services/locations.service.js +10 -5
  43. package/dist/mjs/services/roles.service.js +10 -5
  44. package/dist/mjs/services/service.d.ts +2 -0
  45. package/dist/mjs/services/service.js +22 -1
  46. package/dist/mjs/services/settings.service.js +3 -2
  47. package/dist/mjs/services/shifts.service.d.ts +3 -3
  48. package/dist/mjs/services/shifts.service.js +21 -9
  49. package/dist/mjs/services/users.service.js +10 -5
  50. package/dist/mjs/version.js +1 -1
  51. package/package.json +1 -1
  52. package/src/models/SDKError.model.ts +20 -0
  53. package/src/models/index.ts +1 -1
  54. package/src/services/accounts.service.ts +3 -5
  55. package/src/services/attendance.service.ts +10 -17
  56. package/src/services/auth.service.ts +3 -5
  57. package/src/services/availability.service.ts +1 -5
  58. package/src/services/daily-budgets.service.ts +1 -5
  59. package/src/services/daily-revenue.service.ts +1 -5
  60. package/src/services/day-notes.service.ts +10 -18
  61. package/src/services/days-off.service.ts +2 -10
  62. package/src/services/groups.service.ts +10 -18
  63. package/src/services/leave-embargoes.service.ts +10 -17
  64. package/src/services/leave-request.service.ts +10 -17
  65. package/src/services/leave.service.ts +11 -17
  66. package/src/services/locations.service.ts +11 -17
  67. package/src/services/roles.service.ts +11 -17
  68. package/src/services/service.ts +29 -2
  69. package/src/services/settings.service.ts +4 -5
  70. package/src/services/shifts.service.ts +28 -34
  71. package/src/services/users.service.ts +11 -17
  72. package/src/version.ts +1 -1
  73. package/dist/cjs/models/error-response.model.d.ts +0 -8
  74. package/dist/cjs/models/error-response.model.js +0 -13
  75. package/dist/mjs/models/error-response.model.d.ts +0 -8
  76. package/dist/mjs/models/error-response.model.js +0 -8
  77. package/src/models/error-response.model.ts +0 -14
@@ -0,0 +1,11 @@
1
+ export interface SDKErrorConfig {
2
+ message?: string;
3
+ code?: number;
4
+ data?: unknown;
5
+ }
6
+ export declare class SDKError extends Error {
7
+ readonly code?: number;
8
+ readonly data?: unknown;
9
+ name: string;
10
+ constructor(errorConfig: SDKErrorConfig);
11
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SDKError = void 0;
4
+ class SDKError extends Error {
5
+ constructor(errorConfig) {
6
+ var _a;
7
+ super(errorConfig.message);
8
+ this.name = this.constructor.name;
9
+ (_a = Error.captureStackTrace) === null || _a === void 0 ? void 0 : _a.call(Error, this, SDKError);
10
+ // optional chaining needed as is v8 specific https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#static_methods
11
+ this.data = errorConfig.data;
12
+ this.code = errorConfig.code;
13
+ }
14
+ }
15
+ exports.SDKError = SDKError;
@@ -9,7 +9,7 @@ export * from './day-note.model.js';
9
9
  export * from './days-off-pattern.model.js';
10
10
  export * from './days-off.model.js';
11
11
  export * from './document.model.js';
12
- export * from './error-response.model.js';
12
+ export * from './SDKError.model.js';
13
13
  export * from './group.model.js';
14
14
  export * from './holiday-allowance-custom.model.js';
15
15
  export * from './holiday-allowance.model.js';
@@ -21,7 +21,7 @@ __exportStar(require("./day-note.model.js"), exports);
21
21
  __exportStar(require("./days-off-pattern.model.js"), exports);
22
22
  __exportStar(require("./days-off.model.js"), exports);
23
23
  __exportStar(require("./document.model.js"), exports);
24
- __exportStar(require("./error-response.model.js"), exports);
24
+ __exportStar(require("./SDKError.model.js"), exports);
25
25
  __exportStar(require("./group.model.js"), exports);
26
26
  __exportStar(require("./holiday-allowance-custom.model.js"), exports);
27
27
  __exportStar(require("./holiday-allowance.model.js"), exports);
@@ -31,14 +31,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
31
31
  exports.AccountsService = void 0;
32
32
  const account_model_js_1 = require("../models/account.model.js");
33
33
  const index_js_1 = require("./index.js");
34
- const error_response_model_js_1 = require("../models/error-response.model.js");
35
34
  class AccountsService extends index_js_1.Service {
36
35
  constructor() {
37
36
  super(...arguments);
38
37
  this.apiPath = '/accounts';
39
38
  }
40
39
  get(id, options) {
41
- return super.fetch({ url: `${this.apiPath}/${id}` }, options).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new account_model_js_1.Account(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
40
+ return super
41
+ .fetch({ url: `${this.apiPath}/${id}` }, options)
42
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new account_model_js_1.Account(res.data)));
42
43
  }
43
44
  list(options) {
44
45
  const _super = Object.create(null, {
@@ -31,17 +31,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
31
31
  exports.AttendanceService = void 0;
32
32
  const index_js_1 = require("./index.js");
33
33
  const attendance_model_js_1 = require("../models/attendance.model.js");
34
- const error_response_model_js_1 = require("../models/error-response.model.js");
35
34
  class AttendanceService extends index_js_1.Service {
36
35
  constructor() {
37
36
  super(...arguments);
38
37
  this.apiPath = '/attendance';
39
38
  }
40
39
  create(data, options) {
41
- return super.fetch({ url: this.apiPath, data, method: 'POST' }).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new attendance_model_js_1.Attendance(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
40
+ return super
41
+ .fetch({ url: this.apiPath, data, method: 'POST' })
42
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new attendance_model_js_1.Attendance(res.data)));
42
43
  }
43
44
  get(id, options) {
44
- return super.fetch({ url: `${this.apiPath}/${id}` }, options).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new attendance_model_js_1.Attendance(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
45
+ return super.fetch({ url: `${this.apiPath}/${id}` }, options).then((res) => {
46
+ return Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new attendance_model_js_1.Attendance(res.data));
47
+ });
45
48
  }
46
49
  list(query, options) {
47
50
  const _super = Object.create(null, {
@@ -94,10 +97,12 @@ class AttendanceService extends index_js_1.Service {
94
97
  data,
95
98
  method: 'POST',
96
99
  })
97
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new attendance_model_js_1.Attendance(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
100
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new attendance_model_js_1.Attendance(res.data)));
98
101
  }
99
102
  delete(id, options) {
100
- return super.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' }).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
103
+ return super
104
+ .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
105
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
101
106
  }
102
107
  }
103
108
  exports.AttendanceService = AttendanceService;
@@ -3,14 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AuthService = void 0;
4
4
  const index_js_1 = require("./index.js");
5
5
  const auth_model_js_1 = require("../models/auth.model.js");
6
- const error_response_model_js_1 = require("../models/error-response.model.js");
7
6
  class AuthService extends index_js_1.Service {
8
7
  constructor() {
9
8
  super(...arguments);
10
9
  this.apiPath = '/auth';
11
10
  }
12
11
  get(options) {
13
- return super.fetch({ url: this.apiPath }, options).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new auth_model_js_1.Auth(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
12
+ return super
13
+ .fetch({ url: this.apiPath }, options)
14
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new auth_model_js_1.Auth(res.data)));
14
15
  }
15
16
  }
16
17
  exports.AuthService = AuthService;
@@ -22,7 +22,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.AvailabilityService = void 0;
23
23
  const index_js_1 = require("./index.js");
24
24
  const availability_model_js_1 = require("../models/availability.model.js");
25
- const error_response_model_js_1 = require("../models/error-response.model.js");
26
25
  class AvailabilityService extends index_js_1.Service {
27
26
  constructor() {
28
27
  super(...arguments);
@@ -35,7 +34,7 @@ class AvailabilityService extends index_js_1.Service {
35
34
  data,
36
35
  method: 'POST',
37
36
  })
38
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new availability_model_js_1.Availability(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
37
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new availability_model_js_1.Availability(res.data)));
39
38
  }
40
39
  create(data, options) {
41
40
  return this.update(data, options);
@@ -31,7 +31,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
31
31
  exports.DailyBudgetsService = void 0;
32
32
  const index_js_1 = require("./index.js");
33
33
  const daily_budgets_model_js_1 = require("../models/daily-budgets.model.js");
34
- const error_response_model_js_1 = require("../models/error-response.model.js");
35
34
  class DailyBudgetsService extends index_js_1.Service {
36
35
  constructor() {
37
36
  super(...arguments);
@@ -88,7 +87,7 @@ class DailyBudgetsService extends index_js_1.Service {
88
87
  data,
89
88
  method: 'POST',
90
89
  })
91
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
90
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
92
91
  }
93
92
  }
94
93
  exports.DailyBudgetsService = DailyBudgetsService;
@@ -31,7 +31,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
31
31
  exports.DailyRevenueService = void 0;
32
32
  const index_js_1 = require("./index.js");
33
33
  const daily_revenue_model_js_1 = require("../models/daily-revenue.model.js");
34
- const error_response_model_js_1 = require("../models/error-response.model.js");
35
34
  class DailyRevenueService extends index_js_1.Service {
36
35
  constructor() {
37
36
  super(...arguments);
@@ -88,7 +87,7 @@ class DailyRevenueService extends index_js_1.Service {
88
87
  data,
89
88
  method: 'POST',
90
89
  })
91
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
90
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
92
91
  }
93
92
  }
94
93
  exports.DailyRevenueService = DailyRevenueService;
@@ -30,7 +30,6 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
30
30
  Object.defineProperty(exports, "__esModule", { value: true });
31
31
  exports.DayNotesService = void 0;
32
32
  const index_js_1 = require("./index.js");
33
- const error_response_model_js_1 = require("../models/error-response.model.js");
34
33
  const day_note_model_js_1 = require("../models/day-note.model.js");
35
34
  class DayNotesService extends index_js_1.Service {
36
35
  constructor() {
@@ -38,10 +37,14 @@ class DayNotesService extends index_js_1.Service {
38
37
  this.apiPath = '/day_notes';
39
38
  }
40
39
  create(data, options) {
41
- return super.fetch({ url: this.apiPath, data, method: 'POST' }).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new day_note_model_js_1.DayNote(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
40
+ return super
41
+ .fetch({ url: this.apiPath, data, method: 'POST' })
42
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new day_note_model_js_1.DayNote(res.data)));
42
43
  }
43
44
  get(id, options) {
44
- return super.fetch({ url: `${this.apiPath}/${id}` }, options).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new day_note_model_js_1.DayNote(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
45
+ return super
46
+ .fetch({ url: `${this.apiPath}/${id}` }, options)
47
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new day_note_model_js_1.DayNote(res.data)));
45
48
  }
46
49
  list(query, options) {
47
50
  const _super = Object.create(null, {
@@ -94,10 +97,12 @@ class DayNotesService extends index_js_1.Service {
94
97
  data,
95
98
  method: 'POST',
96
99
  })
97
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new day_note_model_js_1.DayNote(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
100
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new day_note_model_js_1.DayNote(res.data)));
98
101
  }
99
102
  delete(id, options) {
100
- return super.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' }).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
103
+ return super
104
+ .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
105
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
101
106
  }
102
107
  }
103
108
  exports.DayNotesService = DayNotesService;
@@ -30,7 +30,6 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
30
30
  Object.defineProperty(exports, "__esModule", { value: true });
31
31
  exports.DaysOffService = void 0;
32
32
  const index_js_1 = require("./index.js");
33
- const error_response_model_js_1 = require("../models/error-response.model.js");
34
33
  const days_off_model_js_1 = require("../models/days-off.model.js");
35
34
  class DaysOffService extends index_js_1.Service {
36
35
  constructor() {
@@ -47,7 +46,7 @@ class DaysOffService extends index_js_1.Service {
47
46
  },
48
47
  method: 'POST',
49
48
  })
50
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
49
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
51
50
  }
52
51
  list(query, options) {
53
52
  const _super = Object.create(null, {
@@ -103,7 +102,7 @@ class DaysOffService extends index_js_1.Service {
103
102
  users,
104
103
  },
105
104
  })
106
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
105
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
107
106
  }
108
107
  }
109
108
  exports.DaysOffService = DaysOffService;
@@ -30,7 +30,6 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
30
30
  Object.defineProperty(exports, "__esModule", { value: true });
31
31
  exports.GroupsService = void 0;
32
32
  const index_js_1 = require("./index.js");
33
- const error_response_model_js_1 = require("../models/error-response.model.js");
34
33
  const group_model_js_1 = require("../models/group.model.js");
35
34
  class GroupsService extends index_js_1.Service {
36
35
  constructor() {
@@ -38,10 +37,14 @@ class GroupsService extends index_js_1.Service {
38
37
  this.apiPath = '/groups';
39
38
  }
40
39
  create(data, options) {
41
- return super.fetch({ url: this.apiPath, data, method: 'POST' }).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new group_model_js_1.Group(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
40
+ return super
41
+ .fetch({ url: this.apiPath, data, method: 'POST' })
42
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new group_model_js_1.Group(res.data)));
42
43
  }
43
44
  get(id, options) {
44
- return super.fetch({ url: `${this.apiPath}/${id}` }, options).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new group_model_js_1.Group(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
45
+ return super
46
+ .fetch({ url: `${this.apiPath}/${id}` }, options)
47
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new group_model_js_1.Group(res.data)));
45
48
  }
46
49
  list(query, options) {
47
50
  const _super = Object.create(null, {
@@ -94,10 +97,12 @@ class GroupsService extends index_js_1.Service {
94
97
  data,
95
98
  method: 'POST',
96
99
  })
97
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new group_model_js_1.Group(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
100
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new group_model_js_1.Group(res.data)));
98
101
  }
99
102
  delete(id, options) {
100
- return super.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' }).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
103
+ return super
104
+ .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
105
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
101
106
  }
102
107
  }
103
108
  exports.GroupsService = GroupsService;
@@ -31,17 +31,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
31
31
  exports.LeaveEmbargoesService = void 0;
32
32
  const index_js_1 = require("./index.js");
33
33
  const leave_embargo_model_js_1 = require("../models/leave-embargo.model.js");
34
- const error_response_model_js_1 = require("../models/error-response.model.js");
35
34
  class LeaveEmbargoesService extends index_js_1.Service {
36
35
  constructor() {
37
36
  super(...arguments);
38
37
  this.apiPath = '/leave_embargoes';
39
38
  }
40
39
  create(data, options) {
41
- return super.fetch({ url: this.apiPath, data, method: 'POST' }).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new leave_embargo_model_js_1.LeaveEmbargo(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
40
+ return super
41
+ .fetch({ url: this.apiPath, data, method: 'POST' })
42
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new leave_embargo_model_js_1.LeaveEmbargo(res.data)));
42
43
  }
43
44
  get(id, options) {
44
- return super.fetch({ url: `${this.apiPath}/${id}` }, options).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new leave_embargo_model_js_1.LeaveEmbargo(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
45
+ return super
46
+ .fetch({ url: `${this.apiPath}/${id}` }, options)
47
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new leave_embargo_model_js_1.LeaveEmbargo(res.data)));
45
48
  }
46
49
  list(query, options) {
47
50
  const _super = Object.create(null, {
@@ -94,10 +97,12 @@ class LeaveEmbargoesService extends index_js_1.Service {
94
97
  data,
95
98
  method: 'POST',
96
99
  })
97
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new leave_embargo_model_js_1.LeaveEmbargo(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
100
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new leave_embargo_model_js_1.LeaveEmbargo(res.data)));
98
101
  }
99
102
  delete(id, options) {
100
- return super.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' }).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
103
+ return super
104
+ .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
105
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
101
106
  }
102
107
  }
103
108
  exports.LeaveEmbargoesService = LeaveEmbargoesService;
@@ -30,7 +30,6 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
30
30
  Object.defineProperty(exports, "__esModule", { value: true });
31
31
  exports.LeaveRequestService = void 0;
32
32
  const index_js_1 = require("./index.js");
33
- const error_response_model_js_1 = require("../models/error-response.model.js");
34
33
  const leave_request_model_js_1 = require("../models/leave-request.model.js");
35
34
  class LeaveRequestService extends index_js_1.Service {
36
35
  constructor() {
@@ -38,10 +37,14 @@ class LeaveRequestService extends index_js_1.Service {
38
37
  this.apiPath = '/leave_requests';
39
38
  }
40
39
  create(data, options) {
41
- return super.fetch({ url: this.apiPath, data, method: 'POST' }).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new leave_request_model_js_1.LeaveRequest(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
40
+ return super
41
+ .fetch({ url: this.apiPath, data, method: 'POST' })
42
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new leave_request_model_js_1.LeaveRequest(res.data)));
42
43
  }
43
44
  get(id, options) {
44
- return super.fetch({ url: `${this.apiPath}/${id}` }, options).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new leave_request_model_js_1.LeaveRequest(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
45
+ return super
46
+ .fetch({ url: `${this.apiPath}/${id}` }, options)
47
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new leave_request_model_js_1.LeaveRequest(res.data)));
45
48
  }
46
49
  list(query, options) {
47
50
  const _super = Object.create(null, {
@@ -94,10 +97,12 @@ class LeaveRequestService extends index_js_1.Service {
94
97
  data,
95
98
  method: 'POST',
96
99
  })
97
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new leave_request_model_js_1.LeaveRequest(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
100
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new leave_request_model_js_1.LeaveRequest(res.data)));
98
101
  }
99
102
  delete(id, options) {
100
- return super.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' }).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
103
+ return super
104
+ .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
105
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
101
106
  }
102
107
  }
103
108
  exports.LeaveRequestService = LeaveRequestService;
@@ -31,7 +31,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
31
31
  exports.LeaveService = void 0;
32
32
  const index_js_1 = require("./index.js");
33
33
  const leave_model_js_1 = require("../models/leave.model.js");
34
- const error_response_model_js_1 = require("../models/error-response.model.js");
35
34
  const leave_type_model_js_1 = require("../models/leave-type.model.js");
36
35
  class LeaveService extends index_js_1.Service {
37
36
  constructor() {
@@ -39,10 +38,14 @@ class LeaveService extends index_js_1.Service {
39
38
  this.apiPath = '/leave';
40
39
  }
41
40
  create(data, options) {
42
- return super.fetch({ url: this.apiPath, data, method: 'POST' }).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : [...res.data.map((leave) => new leave_model_js_1.Leave(leave))]), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
41
+ return super
42
+ .fetch({ url: this.apiPath, data, method: 'POST' })
43
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : [...res.data.map((leave) => new leave_model_js_1.Leave(leave))]));
43
44
  }
44
45
  get(id, options) {
45
- return super.fetch({ url: `${this.apiPath}/${id}` }, options).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new leave_model_js_1.Leave(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
46
+ return super
47
+ .fetch({ url: `${this.apiPath}/${id}` }, options)
48
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new leave_model_js_1.Leave(res.data)));
46
49
  }
47
50
  list(query, options) {
48
51
  const _super = Object.create(null, {
@@ -116,10 +119,12 @@ class LeaveService extends index_js_1.Service {
116
119
  data,
117
120
  method: 'POST',
118
121
  })
119
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new leave_model_js_1.Leave(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
122
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new leave_model_js_1.Leave(res.data)));
120
123
  }
121
124
  delete(id, options) {
122
- return super.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' }).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
125
+ return super
126
+ .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
127
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
123
128
  }
124
129
  }
125
130
  exports.LeaveService = LeaveService;
@@ -31,17 +31,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
31
31
  exports.LocationsService = void 0;
32
32
  const index_js_1 = require("./index.js");
33
33
  const location_model_js_1 = require("../models/location.model.js");
34
- const error_response_model_js_1 = require("../models/error-response.model.js");
35
34
  class LocationsService extends index_js_1.Service {
36
35
  constructor() {
37
36
  super(...arguments);
38
37
  this.apiPath = '/locations';
39
38
  }
40
39
  create(data, options) {
41
- return super.fetch({ url: `${this.apiPath}`, data, method: 'POST' }).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new location_model_js_1.Location(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
40
+ return super
41
+ .fetch({ url: `${this.apiPath}`, data, method: 'POST' })
42
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new location_model_js_1.Location(res.data)));
42
43
  }
43
44
  get(id, options) {
44
- return super.fetch({ url: `${this.apiPath}/${id}` }, options).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new location_model_js_1.Location(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
45
+ return super
46
+ .fetch({ url: `${this.apiPath}/${id}` }, options)
47
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new location_model_js_1.Location(res.data)));
45
48
  }
46
49
  list(query, options) {
47
50
  const _super = Object.create(null, {
@@ -94,10 +97,12 @@ class LocationsService extends index_js_1.Service {
94
97
  data,
95
98
  method: 'POST',
96
99
  })
97
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new location_model_js_1.Location(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
100
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new location_model_js_1.Location(res.data)));
98
101
  }
99
102
  delete(id, options) {
100
- return super.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' }).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
103
+ return super
104
+ .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
105
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
101
106
  }
102
107
  }
103
108
  exports.LocationsService = LocationsService;
@@ -31,17 +31,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
31
31
  exports.RolesService = void 0;
32
32
  const index_js_1 = require("./index.js");
33
33
  const role_model_js_1 = require("../models/role.model.js");
34
- const error_response_model_js_1 = require("../models/error-response.model.js");
35
34
  class RolesService extends index_js_1.Service {
36
35
  constructor() {
37
36
  super(...arguments);
38
37
  this.apiPath = '/roles';
39
38
  }
40
39
  create(data, options) {
41
- return super.fetch({ url: this.apiPath, data, method: 'POST' }).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new role_model_js_1.Role(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
40
+ return super
41
+ .fetch({ url: this.apiPath, data, method: 'POST' })
42
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new role_model_js_1.Role(res.data)));
42
43
  }
43
44
  get(id, options) {
44
- return super.fetch({ url: `${this.apiPath}/${id}` }, options).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new role_model_js_1.Role(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
45
+ return super
46
+ .fetch({ url: `${this.apiPath}/${id}` }, options)
47
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new role_model_js_1.Role(res.data)));
45
48
  }
46
49
  list(query, options) {
47
50
  const _super = Object.create(null, {
@@ -94,10 +97,12 @@ class RolesService extends index_js_1.Service {
94
97
  data,
95
98
  method: 'POST',
96
99
  })
97
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new role_model_js_1.Role(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
100
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new role_model_js_1.Role(res.data)));
98
101
  }
99
102
  delete(id, options) {
100
- return super.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' }).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
103
+ return super
104
+ .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
105
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
101
106
  }
102
107
  }
103
108
  exports.RolesService = RolesService;
@@ -25,6 +25,8 @@ export interface Options {
25
25
  }
26
26
  export declare abstract class Service<ApiResponse = any> {
27
27
  protected client: AxiosInstance;
28
+ private initialiseAxios;
29
+ private parseClientError;
28
30
  isLeaveRequest(endpoint?: string): boolean;
29
31
  private buildQueryStr;
30
32
  private parsePageLinkHeader;
@@ -32,6 +32,7 @@ const axios_1 = __importDefault(require("axios"));
32
32
  const axios_retry_1 = __importDefault(require("axios-retry"));
33
33
  const rotacloud_js_1 = require("../rotacloud.js");
34
34
  const version_js_1 = require("../version.js");
35
+ const SDKError_model_js_1 = require("../models/SDKError.model.js");
35
36
  var RetryStrategy;
36
37
  (function (RetryStrategy) {
37
38
  RetryStrategy["Exponential"] = "expo";
@@ -52,7 +53,28 @@ const DEFAULT_RETRY_STRATEGY_OPTIONS = {
52
53
  };
53
54
  class Service {
54
55
  constructor() {
55
- this.client = axios_1.default.create();
56
+ this.client = this.initialiseAxios();
57
+ }
58
+ initialiseAxios() {
59
+ const client = axios_1.default.create();
60
+ client.interceptors.response.use((response) => response, (error) => {
61
+ const parsedError = this.parseClientError(error);
62
+ return Promise.reject(parsedError);
63
+ });
64
+ return client;
65
+ }
66
+ parseClientError(error) {
67
+ var _a;
68
+ if (!axios_1.default.isAxiosError(error))
69
+ return error;
70
+ const axiosErrorLocation = error.response || error.request;
71
+ const apiErrorMessage = (_a = axiosErrorLocation.data) === null || _a === void 0 ? void 0 : _a.error;
72
+ const sdkErrorParams = {
73
+ code: axiosErrorLocation.status,
74
+ message: apiErrorMessage || error.message,
75
+ data: axiosErrorLocation.data,
76
+ };
77
+ return new SDKError_model_js_1.SDKError(sdkErrorParams);
56
78
  }
57
79
  isLeaveRequest(endpoint) {
58
80
  return endpoint === '/leave_requests';
@@ -3,14 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SettingsService = void 0;
4
4
  const settings_model_js_1 = require("../models/settings.model.js");
5
5
  const index_js_1 = require("./index.js");
6
- const error_response_model_js_1 = require("../models/error-response.model.js");
7
6
  class SettingsService extends index_js_1.Service {
8
7
  constructor() {
9
8
  super(...arguments);
10
9
  this.apiPath = '/settings';
11
10
  }
12
11
  get(query, options) {
13
- return super.fetch({ url: `${this.apiPath}`, params: query }, options).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new settings_model_js_1.Settings(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
12
+ return super
13
+ .fetch({ url: `${this.apiPath}`, params: query }, options)
14
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new settings_model_js_1.Settings(res.data)));
14
15
  }
15
16
  }
16
17
  exports.SettingsService = SettingsService;
@@ -24,11 +24,11 @@ export declare class ShiftsService extends Service {
24
24
  rawResponse: true;
25
25
  } & Options): Promise<AxiosResponse<ApiShift, any>>;
26
26
  update(id: number, data: Partial<ApiShift>, options: Options): Promise<Shift>;
27
- delete(id: number): Promise<number>;
28
- delete(id: number, options: {
27
+ delete(ids: number | number[]): Promise<number>;
28
+ delete(ids: number | number[], options: {
29
29
  rawResponse: true;
30
30
  } & Options): Promise<AxiosResponse<any, any>>;
31
- delete(id: number, options: Options): Promise<number>;
31
+ delete(ids: number | number[], options: Options): Promise<number>;
32
32
  acknowledge(data: number[]): Promise<number>;
33
33
  acknowledge(data: number[], options: {
34
34
  rawResponse: true;