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
|
@@ -3,7 +3,7 @@ import { ApiLeave, ApiLeaveType } from '../interfaces/index.js';
|
|
|
3
3
|
import { Service, Options, RequirementsOf } from './index.js';
|
|
4
4
|
|
|
5
5
|
import { Leave } from '../models/leave.model.js';
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
import { LeaveQueryParams } from '../interfaces/query-params/leave-query-params.interface.js';
|
|
8
8
|
|
|
9
9
|
import { LeaveType } from '../models/leave-type.model.js';
|
|
@@ -20,20 +20,18 @@ export class LeaveService extends Service {
|
|
|
20
20
|
): Promise<AxiosResponse<ApiLeave[], any>>;
|
|
21
21
|
create(data: RequirementsOf<ApiLeave, RequiredProps>, options: Options): Promise<Leave[]>;
|
|
22
22
|
create(data: RequirementsOf<ApiLeave, RequiredProps>, options?: Options) {
|
|
23
|
-
return super
|
|
24
|
-
|
|
25
|
-
(
|
|
26
|
-
);
|
|
23
|
+
return super
|
|
24
|
+
.fetch<ApiLeave[]>({ url: this.apiPath, data, method: 'POST' })
|
|
25
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : [...res.data.map((leave) => new Leave(leave))]));
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
get(id: number): Promise<Leave>;
|
|
30
29
|
get(id: number, options: { rawResponse: true }): Promise<AxiosResponse<ApiLeave, any>>;
|
|
31
30
|
get(id: number, options: Options): Promise<Leave>;
|
|
32
31
|
get(id: number, options?: Options) {
|
|
33
|
-
return super
|
|
34
|
-
(
|
|
35
|
-
(
|
|
36
|
-
);
|
|
32
|
+
return super
|
|
33
|
+
.fetch<ApiLeave>({ url: `${this.apiPath}/${id}` }, options)
|
|
34
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Leave(res.data)));
|
|
37
35
|
}
|
|
38
36
|
|
|
39
37
|
async *list(query: LeaveQueryParams, options?: Options) {
|
|
@@ -75,19 +73,15 @@ export class LeaveService extends Service {
|
|
|
75
73
|
data,
|
|
76
74
|
method: 'POST',
|
|
77
75
|
})
|
|
78
|
-
.then(
|
|
79
|
-
(res) => Promise.resolve(options?.rawResponse ? res : new Leave(res.data)),
|
|
80
|
-
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
81
|
-
);
|
|
76
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Leave(res.data)));
|
|
82
77
|
}
|
|
83
78
|
|
|
84
79
|
delete(id: number): Promise<number>;
|
|
85
80
|
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiLeave, any>>;
|
|
86
81
|
delete(id: number, options: Options): Promise<number>;
|
|
87
82
|
delete(id: number, options?: Options) {
|
|
88
|
-
return super
|
|
89
|
-
(
|
|
90
|
-
(
|
|
91
|
-
);
|
|
83
|
+
return super
|
|
84
|
+
.fetch<ApiLeave>({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
|
|
85
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
92
86
|
}
|
|
93
87
|
}
|
|
@@ -3,7 +3,7 @@ import { ApiLocation } from '../interfaces/index.js';
|
|
|
3
3
|
import { Service, Options, RequirementsOf } from './index.js';
|
|
4
4
|
|
|
5
5
|
import { Location } from '../models/location.model.js';
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
import { LocationsQueryParams } from '../interfaces/query-params/locations-query-params.interface.js';
|
|
8
8
|
|
|
9
9
|
type RequiredProps = 'name';
|
|
@@ -18,20 +18,18 @@ export class LocationsService extends Service {
|
|
|
18
18
|
): Promise<AxiosResponse<ApiLocation, any>>;
|
|
19
19
|
create(data: RequirementsOf<ApiLocation, RequiredProps>, options: Options): Promise<Location>;
|
|
20
20
|
create(data: RequirementsOf<ApiLocation, RequiredProps>, options?: Options) {
|
|
21
|
-
return super
|
|
22
|
-
(
|
|
23
|
-
(
|
|
24
|
-
);
|
|
21
|
+
return super
|
|
22
|
+
.fetch<ApiLocation>({ url: `${this.apiPath}`, data, method: 'POST' })
|
|
23
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Location(res.data)));
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
get(id: number): Promise<Location>;
|
|
28
27
|
get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiLocation, any>>;
|
|
29
28
|
get(id: number, options: Options): Promise<Location>;
|
|
30
29
|
get(id: number, options?: Options) {
|
|
31
|
-
return super
|
|
32
|
-
(
|
|
33
|
-
(
|
|
34
|
-
);
|
|
30
|
+
return super
|
|
31
|
+
.fetch<ApiLocation>({ url: `${this.apiPath}/${id}` }, options)
|
|
32
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Location(res.data)));
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
async *list(query?: LocationsQueryParams, options?: Options) {
|
|
@@ -67,19 +65,15 @@ export class LocationsService extends Service {
|
|
|
67
65
|
data,
|
|
68
66
|
method: 'POST',
|
|
69
67
|
})
|
|
70
|
-
.then(
|
|
71
|
-
(res) => Promise.resolve(options?.rawResponse ? res : new Location(res.data)),
|
|
72
|
-
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
73
|
-
);
|
|
68
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Location(res.data)));
|
|
74
69
|
}
|
|
75
70
|
|
|
76
71
|
delete(id: number): Promise<number>;
|
|
77
72
|
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<any, any>>;
|
|
78
73
|
delete(id: number, options: Options): Promise<number>;
|
|
79
74
|
delete(id: number, options?: Options) {
|
|
80
|
-
return super
|
|
81
|
-
(
|
|
82
|
-
(
|
|
83
|
-
);
|
|
75
|
+
return super
|
|
76
|
+
.fetch<ApiLocation>({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
|
|
77
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
84
78
|
}
|
|
85
79
|
}
|
|
@@ -3,7 +3,7 @@ import { ApiRole } from '../interfaces/index.js';
|
|
|
3
3
|
import { Service, Options, RequirementsOf } from './index.js';
|
|
4
4
|
|
|
5
5
|
import { Role } from '../models/role.model.js';
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
import { RolesQueryParams } from '../interfaces/query-params/roles-query-params.interface.js';
|
|
8
8
|
|
|
9
9
|
type RequiredProps = 'name';
|
|
@@ -18,20 +18,18 @@ export class RolesService extends Service {
|
|
|
18
18
|
): Promise<AxiosResponse<ApiRole, any>>;
|
|
19
19
|
create(data: RequirementsOf<ApiRole, RequiredProps>, options: Options): Promise<Role>;
|
|
20
20
|
create(data: RequirementsOf<ApiRole, RequiredProps>, options?: Options) {
|
|
21
|
-
return super
|
|
22
|
-
(
|
|
23
|
-
(
|
|
24
|
-
);
|
|
21
|
+
return super
|
|
22
|
+
.fetch<ApiRole>({ url: this.apiPath, data, method: 'POST' })
|
|
23
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Role(res.data)));
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
get(id: number): Promise<Role>;
|
|
28
27
|
get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiRole, any>>;
|
|
29
28
|
get(id: number, options: Options): Promise<Role>;
|
|
30
29
|
get(id: number, options?: Options) {
|
|
31
|
-
return super
|
|
32
|
-
(
|
|
33
|
-
(
|
|
34
|
-
);
|
|
30
|
+
return super
|
|
31
|
+
.fetch<ApiRole>({ url: `${this.apiPath}/${id}` }, options)
|
|
32
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Role(res.data)));
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
async *list(query?: RolesQueryParams, options?: Options) {
|
|
@@ -66,19 +64,15 @@ export class RolesService extends Service {
|
|
|
66
64
|
data,
|
|
67
65
|
method: 'POST',
|
|
68
66
|
})
|
|
69
|
-
.then(
|
|
70
|
-
(res) => Promise.resolve(options?.rawResponse ? res : new Role(res.data)),
|
|
71
|
-
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
72
|
-
);
|
|
67
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Role(res.data)));
|
|
73
68
|
}
|
|
74
69
|
|
|
75
70
|
delete(id: number): Promise<number>;
|
|
76
71
|
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<any, any>>;
|
|
77
72
|
delete(id: number, options: Options): Promise<number>;
|
|
78
73
|
delete(id: number, options?: Options) {
|
|
79
|
-
return super
|
|
80
|
-
(
|
|
81
|
-
(
|
|
82
|
-
);
|
|
74
|
+
return super
|
|
75
|
+
.fetch<ApiRole>({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
|
|
76
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
83
77
|
}
|
|
84
78
|
}
|
package/src/services/service.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import axios, { AxiosInstance, AxiosRequestConfig, AxiosRequestHeaders, AxiosResponse } from 'axios';
|
|
1
|
+
import axios, { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosRequestHeaders, AxiosResponse } from 'axios';
|
|
2
2
|
import axiosRetry from 'axios-retry';
|
|
3
3
|
import { RotaCloud } from '../rotacloud.js';
|
|
4
4
|
import { Version } from '../version.js';
|
|
5
|
+
import { SDKErrorConfig, SDKError } from '../models/SDKError.model.js';
|
|
5
6
|
|
|
6
7
|
export type RequirementsOf<T, K extends keyof T> = Required<Pick<T, K>> & Partial<T>;
|
|
7
8
|
|
|
@@ -59,7 +60,33 @@ type ParameterPrimitive = string | boolean | number | null;
|
|
|
59
60
|
type ParameterValue = ParameterPrimitive | ParameterPrimitive[] | undefined;
|
|
60
61
|
|
|
61
62
|
export abstract class Service<ApiResponse = any> {
|
|
62
|
-
protected client: AxiosInstance =
|
|
63
|
+
protected client: AxiosInstance = this.initialiseAxios();
|
|
64
|
+
|
|
65
|
+
private initialiseAxios(): AxiosInstance {
|
|
66
|
+
const client = axios.create();
|
|
67
|
+
client.interceptors.response.use(
|
|
68
|
+
(response) => response,
|
|
69
|
+
(error) => {
|
|
70
|
+
const parsedError = this.parseClientError(error);
|
|
71
|
+
|
|
72
|
+
return Promise.reject(parsedError);
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
return client;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private parseClientError(error: unknown | AxiosError): SDKError | unknown {
|
|
79
|
+
if (!axios.isAxiosError(error)) return error;
|
|
80
|
+
const axiosErrorLocation = error.response || error.request;
|
|
81
|
+
const apiErrorMessage = axiosErrorLocation.data?.error;
|
|
82
|
+
const sdkErrorParams: SDKErrorConfig = {
|
|
83
|
+
code: axiosErrorLocation.status,
|
|
84
|
+
message: apiErrorMessage || error.message,
|
|
85
|
+
data: axiosErrorLocation.data,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
return new SDKError(sdkErrorParams);
|
|
89
|
+
}
|
|
63
90
|
|
|
64
91
|
public isLeaveRequest(endpoint?: string): boolean {
|
|
65
92
|
return endpoint === '/leave_requests';
|
|
@@ -3,7 +3,7 @@ import { Settings } from '../models/settings.model.js';
|
|
|
3
3
|
import { Service, Options } from './index.js';
|
|
4
4
|
|
|
5
5
|
import { ApiSettings } from '../interfaces/index.js';
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
import { SettingsQueryParams } from '../rotacloud.js';
|
|
8
8
|
|
|
9
9
|
class SettingsService extends Service {
|
|
@@ -13,10 +13,9 @@ class SettingsService extends Service {
|
|
|
13
13
|
get(query: SettingsQueryParams, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiSettings, any>>;
|
|
14
14
|
get(query: SettingsQueryParams, options: Options): Promise<Settings>;
|
|
15
15
|
get(query: SettingsQueryParams, options?: Options) {
|
|
16
|
-
return super
|
|
17
|
-
(
|
|
18
|
-
(
|
|
19
|
-
);
|
|
16
|
+
return super
|
|
17
|
+
.fetch<ApiSettings>({ url: `${this.apiPath}`, params: query }, options)
|
|
18
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Settings(res.data)));
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AxiosResponse } from 'axios';
|
|
1
|
+
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
2
|
import { ApiShift } from '../interfaces/index.js';
|
|
3
3
|
import { Service, Options, RequirementsOf } from './index.js';
|
|
4
4
|
|
|
5
5
|
import { Shift } from '../models/shift.model.js';
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
import { ShiftsQueryParams } from '../interfaces/query-params/shifts-query-params.interface.js';
|
|
8
8
|
|
|
9
9
|
type RequiredProps = 'end_time' | 'start_time' | 'location';
|
|
@@ -18,20 +18,18 @@ export class ShiftsService extends Service {
|
|
|
18
18
|
): Promise<AxiosResponse<ApiShift, any>>;
|
|
19
19
|
create(data: RequirementsOf<ApiShift, RequiredProps>, options: Options): Promise<Shift>;
|
|
20
20
|
create(data: RequirementsOf<ApiShift, RequiredProps>, options?: Options) {
|
|
21
|
-
return super
|
|
22
|
-
(
|
|
23
|
-
(
|
|
24
|
-
);
|
|
21
|
+
return super
|
|
22
|
+
.fetch<ApiShift>({ url: this.apiPath, data, method: 'POST' })
|
|
23
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Shift(res.data)));
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
get(id: number): Promise<Shift>;
|
|
28
27
|
get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiShift, any>>;
|
|
29
28
|
get(id: number, options: Options): Promise<Shift>;
|
|
30
29
|
get(id: number, options?: Options) {
|
|
31
|
-
return super
|
|
32
|
-
(
|
|
33
|
-
(
|
|
34
|
-
);
|
|
30
|
+
return super
|
|
31
|
+
.fetch<ApiShift>({ url: `${this.apiPath}/${id}` }, options)
|
|
32
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Shift(res.data)));
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
async *list(query: ShiftsQueryParams, options?: Options) {
|
|
@@ -67,49 +65,45 @@ export class ShiftsService extends Service {
|
|
|
67
65
|
data,
|
|
68
66
|
method: 'POST',
|
|
69
67
|
})
|
|
70
|
-
.then(
|
|
71
|
-
(res) => Promise.resolve(options?.rawResponse ? res : new Shift(res.data)),
|
|
72
|
-
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
73
|
-
);
|
|
68
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Shift(res.data)));
|
|
74
69
|
}
|
|
75
70
|
|
|
76
|
-
delete(
|
|
77
|
-
delete(
|
|
78
|
-
delete(
|
|
79
|
-
delete(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
71
|
+
delete(ids: number | number[]): Promise<number>;
|
|
72
|
+
delete(ids: number | number[], options: { rawResponse: true } & Options): Promise<AxiosResponse<any, any>>;
|
|
73
|
+
delete(ids: number | number[], options: Options): Promise<number>;
|
|
74
|
+
delete(ids: number | number[], options?: Options) {
|
|
75
|
+
const params: AxiosRequestConfig =
|
|
76
|
+
typeof ids !== 'number'
|
|
77
|
+
? { url: this.apiPath, data: ids, method: 'DELETE' }
|
|
78
|
+
: { url: `${this.apiPath}/${ids}`, method: 'DELETE' };
|
|
79
|
+
|
|
80
|
+
return super.fetch<ApiShift>(params).then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
84
81
|
}
|
|
85
82
|
|
|
86
83
|
acknowledge(data: number[]): Promise<number>;
|
|
87
84
|
acknowledge(data: number[], options: { rawResponse: true } & Options): Promise<AxiosResponse<any, any>>;
|
|
88
85
|
acknowledge(data: number[], options: Options): Promise<number>;
|
|
89
86
|
acknowledge(data: number[], options?: Options) {
|
|
90
|
-
return super
|
|
91
|
-
(
|
|
92
|
-
(
|
|
93
|
-
);
|
|
87
|
+
return super
|
|
88
|
+
.fetch<ApiShift>({ url: '/shifts_acknowledged', data, method: 'POST' })
|
|
89
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
94
90
|
}
|
|
95
91
|
|
|
96
92
|
publish(data: { shifts: number[] }): Promise<number>;
|
|
97
93
|
publish(data: { shifts: number[] }, options: { rawResponse: true } & Options): Promise<AxiosResponse<any, any>>;
|
|
98
94
|
publish(data: { shifts: number[] }, options: Options): Promise<number>;
|
|
99
95
|
publish(data: { shifts: number[] }, options?: Options) {
|
|
100
|
-
return super
|
|
101
|
-
(
|
|
102
|
-
(
|
|
103
|
-
);
|
|
96
|
+
return super
|
|
97
|
+
.fetch<ApiShift>({ url: '/shifts_published', data, method: 'POST' })
|
|
98
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
104
99
|
}
|
|
105
100
|
|
|
106
101
|
unpublish(data: { shifts: number[] }): Promise<number>;
|
|
107
102
|
unpublish(data: { shifts: number[] }, options: { rawResponse: true } & Options): Promise<AxiosResponse<any, any>>;
|
|
108
103
|
unpublish(data: { shifts: number[] }, options: Options): Promise<number>;
|
|
109
104
|
unpublish(data: { shifts: number[] }, options?: Options) {
|
|
110
|
-
return super
|
|
111
|
-
(
|
|
112
|
-
(
|
|
113
|
-
);
|
|
105
|
+
return super
|
|
106
|
+
.fetch<ApiShift>({ url: '/shifts_published', data, method: 'DELETE' })
|
|
107
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
114
108
|
}
|
|
115
109
|
}
|
|
@@ -3,7 +3,7 @@ import { ApiUser } from '../interfaces/index.js';
|
|
|
3
3
|
import { Service, Options, RequirementsOf } from './index.js';
|
|
4
4
|
|
|
5
5
|
import { User } from '../models/user.model.js';
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
import { UsersQueryParams } from '../interfaces/query-params/users-query-params.interface.js';
|
|
8
8
|
|
|
9
9
|
type RequiredProps = 'first_name' | 'last_name';
|
|
@@ -18,20 +18,18 @@ class UsersService extends Service {
|
|
|
18
18
|
): Promise<AxiosResponse<ApiUser, any>>;
|
|
19
19
|
create(data: RequirementsOf<ApiUser, RequiredProps>, options: Options): Promise<User>;
|
|
20
20
|
create(data: RequirementsOf<ApiUser, RequiredProps>, options?: Options) {
|
|
21
|
-
return super
|
|
22
|
-
(
|
|
23
|
-
(
|
|
24
|
-
);
|
|
21
|
+
return super
|
|
22
|
+
.fetch<ApiUser>({ url: this.apiPath, data, method: 'POST' })
|
|
23
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new User(res.data)));
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
get(id: number): Promise<User>;
|
|
28
27
|
get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiUser, any>>;
|
|
29
28
|
get(id: number, options: Options): Promise<User>;
|
|
30
29
|
get(id: number, options?: Options) {
|
|
31
|
-
return super
|
|
32
|
-
(
|
|
33
|
-
(
|
|
34
|
-
);
|
|
30
|
+
return super
|
|
31
|
+
.fetch<ApiUser>({ url: `${this.apiPath}/${id}` }, options)
|
|
32
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new User(res.data)));
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
async *list(query: UsersQueryParams, options?: Options) {
|
|
@@ -67,20 +65,16 @@ class UsersService extends Service {
|
|
|
67
65
|
data,
|
|
68
66
|
method: 'POST',
|
|
69
67
|
})
|
|
70
|
-
.then(
|
|
71
|
-
(res) => Promise.resolve(options?.rawResponse ? res : new User(res.data)),
|
|
72
|
-
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
73
|
-
);
|
|
68
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new User(res.data)));
|
|
74
69
|
}
|
|
75
70
|
|
|
76
71
|
delete(id: number): Promise<number>;
|
|
77
72
|
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<any, any>>;
|
|
78
73
|
delete(id: number, options: Options): Promise<number>;
|
|
79
74
|
delete(id: number, options?: Options) {
|
|
80
|
-
return super
|
|
81
|
-
(
|
|
82
|
-
(
|
|
83
|
-
);
|
|
75
|
+
return super
|
|
76
|
+
.fetch<ApiUser>({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
|
|
77
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
84
78
|
}
|
|
85
79
|
}
|
|
86
80
|
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const Version = { version: '1.0.
|
|
1
|
+
export const Version = { version: '1.0.41' };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ErrorResponse = void 0;
|
|
4
|
-
class ErrorResponse {
|
|
5
|
-
constructor(err) {
|
|
6
|
-
var _a, _b, _c;
|
|
7
|
-
this.status = (_a = err.response) === null || _a === void 0 ? void 0 : _a.status;
|
|
8
|
-
this.statusText = (_b = err.response) === null || _b === void 0 ? void 0 : _b.statusText;
|
|
9
|
-
this.message = err.message;
|
|
10
|
-
this.data = (_c = err.response) === null || _c === void 0 ? void 0 : _c.data;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.ErrorResponse = ErrorResponse;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { AxiosError } from 'axios';
|
|
2
|
-
|
|
3
|
-
export class ErrorResponse {
|
|
4
|
-
public status: number | undefined;
|
|
5
|
-
public statusText: string | undefined;
|
|
6
|
-
public message: string;
|
|
7
|
-
public data: any;
|
|
8
|
-
constructor(err: AxiosError<any, any>) {
|
|
9
|
-
this.status = err.response?.status;
|
|
10
|
-
this.statusText = err.response?.statusText;
|
|
11
|
-
this.message = err.message;
|
|
12
|
-
this.data = err.response?.data;
|
|
13
|
-
}
|
|
14
|
-
}
|