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.
- package/dist/cjs/models/SDKError.model.d.ts +11 -0
- package/dist/cjs/models/SDKError.model.js +15 -0
- package/dist/cjs/models/index.d.ts +1 -1
- package/dist/cjs/models/index.js +1 -1
- package/dist/cjs/services/accounts.service.js +3 -2
- package/dist/cjs/services/attendance.service.js +10 -5
- package/dist/cjs/services/auth.service.js +3 -2
- package/dist/cjs/services/availability.service.js +1 -2
- package/dist/cjs/services/daily-budgets.service.js +1 -2
- package/dist/cjs/services/daily-revenue.service.js +1 -2
- package/dist/cjs/services/day-notes.service.js +10 -5
- package/dist/cjs/services/days-off.service.js +2 -3
- package/dist/cjs/services/groups.service.js +10 -5
- package/dist/cjs/services/leave-embargoes.service.js +10 -5
- package/dist/cjs/services/leave-request.service.js +10 -5
- package/dist/cjs/services/leave.service.js +10 -5
- package/dist/cjs/services/locations.service.js +10 -5
- package/dist/cjs/services/roles.service.js +10 -5
- package/dist/cjs/services/service.d.ts +2 -0
- package/dist/cjs/services/service.js +23 -1
- package/dist/cjs/services/settings.service.js +3 -2
- package/dist/cjs/services/shifts.service.d.ts +3 -3
- package/dist/cjs/services/shifts.service.js +21 -9
- package/dist/cjs/services/users.service.js +10 -5
- package/dist/cjs/version.js +1 -1
- package/dist/mjs/models/SDKError.model.d.ts +11 -0
- package/dist/mjs/models/SDKError.model.js +10 -0
- package/dist/mjs/models/index.d.ts +1 -1
- package/dist/mjs/models/index.js +1 -1
- package/dist/mjs/services/accounts.service.js +3 -2
- package/dist/mjs/services/attendance.service.js +10 -5
- package/dist/mjs/services/auth.service.js +3 -2
- package/dist/mjs/services/availability.service.js +1 -2
- package/dist/mjs/services/daily-budgets.service.js +1 -2
- package/dist/mjs/services/daily-revenue.service.js +1 -2
- package/dist/mjs/services/day-notes.service.js +10 -5
- package/dist/mjs/services/days-off.service.js +2 -3
- package/dist/mjs/services/groups.service.js +10 -5
- package/dist/mjs/services/leave-embargoes.service.js +10 -5
- package/dist/mjs/services/leave-request.service.js +10 -5
- package/dist/mjs/services/leave.service.js +10 -5
- package/dist/mjs/services/locations.service.js +10 -5
- package/dist/mjs/services/roles.service.js +10 -5
- package/dist/mjs/services/service.d.ts +2 -0
- package/dist/mjs/services/service.js +22 -1
- package/dist/mjs/services/settings.service.js +3 -2
- package/dist/mjs/services/shifts.service.d.ts +3 -3
- package/dist/mjs/services/shifts.service.js +21 -9
- package/dist/mjs/services/users.service.js +10 -5
- package/dist/mjs/version.js +1 -1
- package/package.json +1 -1
- package/src/models/SDKError.model.ts +20 -0
- package/src/models/index.ts +1 -1
- package/src/services/accounts.service.ts +3 -5
- package/src/services/attendance.service.ts +10 -17
- package/src/services/auth.service.ts +3 -5
- package/src/services/availability.service.ts +1 -5
- package/src/services/daily-budgets.service.ts +1 -5
- package/src/services/daily-revenue.service.ts +1 -5
- package/src/services/day-notes.service.ts +10 -18
- package/src/services/days-off.service.ts +2 -10
- package/src/services/groups.service.ts +10 -18
- package/src/services/leave-embargoes.service.ts +10 -17
- package/src/services/leave-request.service.ts +10 -17
- package/src/services/leave.service.ts +11 -17
- package/src/services/locations.service.ts +11 -17
- package/src/services/roles.service.ts +11 -17
- package/src/services/service.ts +29 -2
- package/src/services/settings.service.ts +4 -5
- package/src/services/shifts.service.ts +28 -34
- package/src/services/users.service.ts +11 -17
- package/src/version.ts +1 -1
- package/dist/cjs/models/error-response.model.d.ts +0 -8
- package/dist/cjs/models/error-response.model.js +0 -13
- package/dist/mjs/models/error-response.model.d.ts +0 -8
- package/dist/mjs/models/error-response.model.js +0 -8
- 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 './
|
|
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';
|
package/dist/cjs/models/index.js
CHANGED
|
@@ -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("./
|
|
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
|
|
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
|
|
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) =>
|
|
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))
|
|
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
|
|
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
|
|
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))
|
|
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)
|
|
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)
|
|
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
|
|
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
|
|
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))
|
|
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
|
|
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)
|
|
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)
|
|
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
|
|
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
|
|
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))
|
|
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
|
|
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
|
|
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
|
|
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))
|
|
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
|
|
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
|
|
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
|
|
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))
|
|
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
|
|
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
|
|
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
|
|
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))
|
|
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
|
|
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
|
|
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
|
|
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))
|
|
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
|
|
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
|
|
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
|
|
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))
|
|
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
|
|
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 =
|
|
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
|
|
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(
|
|
28
|
-
delete(
|
|
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(
|
|
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;
|