rotacloud 1.0.28 → 1.0.31
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/README.md +27 -1
- package/dist/cjs/interfaces/index.d.ts +2 -1
- package/dist/cjs/interfaces/index.js +2 -1
- package/dist/cjs/interfaces/query-params/index.d.ts +1 -0
- package/dist/cjs/interfaces/query-params/index.js +1 -0
- package/dist/cjs/interfaces/query-params/settings-query-params.interface.d.ts +3 -0
- package/dist/cjs/interfaces/query-params/settings-query-params.interface.js +2 -0
- package/dist/cjs/interfaces/sdk-config.interface.d.ts +2 -0
- package/dist/cjs/interfaces/settings.interface.d.ts +64 -0
- package/dist/cjs/interfaces/settings.interface.js +2 -0
- package/dist/cjs/models/attendance.model.d.ts +21 -1
- package/dist/cjs/models/attendance.model.js +20 -0
- package/dist/cjs/models/settings.model.d.ts +2 -6
- package/dist/cjs/models/settings.model.js +3 -0
- package/dist/cjs/rotacloud.d.ts +4 -2
- package/dist/cjs/rotacloud.js +10 -6
- package/dist/cjs/services/accounts.service.d.ts +7 -1
- package/dist/cjs/services/accounts.service.js +4 -0
- package/dist/cjs/services/index.d.ts +1 -0
- package/dist/cjs/services/index.js +1 -0
- package/dist/cjs/services/service.d.ts +19 -1
- package/dist/cjs/services/service.js +38 -3
- package/dist/cjs/services/settings.service.d.ts +14 -0
- package/dist/cjs/services/settings.service.js +16 -0
- package/dist/cjs/version.js +1 -1
- package/dist/mjs/interfaces/index.d.ts +2 -1
- package/dist/mjs/interfaces/index.js +2 -1
- package/dist/mjs/interfaces/query-params/index.d.ts +1 -0
- package/dist/mjs/interfaces/query-params/index.js +1 -0
- package/dist/mjs/interfaces/query-params/settings-query-params.interface.d.ts +3 -0
- package/dist/mjs/interfaces/query-params/settings-query-params.interface.js +1 -0
- package/dist/mjs/interfaces/sdk-config.interface.d.ts +2 -0
- package/dist/mjs/interfaces/settings.interface.d.ts +64 -0
- package/dist/mjs/interfaces/settings.interface.js +1 -0
- package/dist/mjs/models/attendance.model.d.ts +21 -1
- package/dist/mjs/models/attendance.model.js +20 -0
- package/dist/mjs/models/settings.model.d.ts +2 -6
- package/dist/mjs/models/settings.model.js +3 -0
- package/dist/mjs/rotacloud.d.ts +4 -2
- package/dist/mjs/rotacloud.js +12 -6
- package/dist/mjs/services/accounts.service.d.ts +7 -1
- package/dist/mjs/services/accounts.service.js +4 -0
- package/dist/mjs/services/index.d.ts +1 -0
- package/dist/mjs/services/index.js +1 -0
- package/dist/mjs/services/service.d.ts +19 -1
- package/dist/mjs/services/service.js +37 -2
- package/dist/mjs/services/settings.service.d.ts +14 -0
- package/dist/mjs/services/settings.service.js +13 -0
- package/dist/mjs/version.js +1 -1
- package/package.json +2 -1
- package/src/interfaces/index.ts +2 -1
- package/src/interfaces/query-params/index.ts +1 -0
- package/src/interfaces/query-params/settings-query-params.interface.ts +3 -0
- package/src/interfaces/sdk-config.interface.ts +3 -0
- package/src/interfaces/settings.interface.ts +63 -0
- package/src/models/attendance.model.ts +41 -1
- package/src/models/settings.model.ts +5 -3
- package/src/rotacloud.ts +14 -5
- package/src/services/accounts.service.ts +12 -0
- package/src/services/index.ts +1 -0
- package/src/services/service.ts +57 -3
- package/src/services/settings.service.ts +23 -0
- package/src/version.ts +1 -1
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
import { ApiAttendance } from '../interfaces/index.js';
|
|
1
|
+
import { ApiAttendance, ApiAttendanceLocation, ApiShift } from '../interfaces/index.js';
|
|
2
2
|
export declare class Attendance {
|
|
3
3
|
id: number;
|
|
4
|
+
deleted: boolean;
|
|
4
5
|
approved: boolean;
|
|
6
|
+
in_time: number;
|
|
7
|
+
out_time: number;
|
|
8
|
+
minutes_break: number;
|
|
9
|
+
user: number;
|
|
5
10
|
location: number;
|
|
11
|
+
role: number;
|
|
12
|
+
minutes_late: number;
|
|
13
|
+
hours: number;
|
|
14
|
+
hours_auto: number;
|
|
15
|
+
hours_is_auto: boolean;
|
|
16
|
+
notes: string | null;
|
|
17
|
+
shift: ApiShift | null;
|
|
18
|
+
in_method: string;
|
|
19
|
+
out_method: string;
|
|
20
|
+
in_location: ApiAttendanceLocation;
|
|
21
|
+
out_location: ApiAttendanceLocation;
|
|
22
|
+
in_device: number;
|
|
23
|
+
out_device: number;
|
|
24
|
+
in_terminal: null;
|
|
25
|
+
out_terminal: null;
|
|
6
26
|
constructor(attendance: ApiAttendance);
|
|
7
27
|
}
|
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
export class Attendance {
|
|
2
2
|
constructor(attendance) {
|
|
3
3
|
this.id = attendance.id;
|
|
4
|
+
this.deleted = attendance.deleted;
|
|
4
5
|
this.approved = attendance.approved;
|
|
6
|
+
this.in_time = attendance.in_time;
|
|
7
|
+
this.out_time = attendance.out_time;
|
|
8
|
+
this.minutes_break = attendance.minutes_break;
|
|
9
|
+
this.user = attendance.user;
|
|
5
10
|
this.location = attendance.location;
|
|
11
|
+
this.role = attendance.role;
|
|
12
|
+
this.minutes_late = attendance.minutes_late;
|
|
13
|
+
this.hours = attendance.hours;
|
|
14
|
+
this.hours_auto = attendance.hours_auto;
|
|
15
|
+
this.hours_is_auto = attendance.hours_is_auto;
|
|
16
|
+
this.notes = attendance.notes;
|
|
17
|
+
this.shift = attendance.shift;
|
|
18
|
+
this.in_method = attendance.in_method;
|
|
19
|
+
this.out_method = attendance.out_method;
|
|
20
|
+
this.in_location = attendance.in_location;
|
|
21
|
+
this.out_location = attendance.out_location;
|
|
22
|
+
this.in_device = attendance.in_device;
|
|
23
|
+
this.out_device = attendance.out_device;
|
|
24
|
+
this.in_terminal = attendance.in_terminal;
|
|
25
|
+
this.out_terminal = attendance.out_terminal;
|
|
6
26
|
}
|
|
7
27
|
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
[pay_code_id: string]: string | {
|
|
3
|
-
[leave_type_id: string]: string;
|
|
4
|
-
};
|
|
5
|
-
}
|
|
1
|
+
import { ApiSettings, PayCodes } from '../interfaces';
|
|
6
2
|
export declare class Settings {
|
|
7
3
|
attendance_record_breaks: string;
|
|
8
4
|
automatically_clock_in_to_consecutive_shifts: boolean;
|
|
@@ -61,5 +57,5 @@ export declare class Settings {
|
|
|
61
57
|
week_starts: string;
|
|
62
58
|
pay_codes: PayCodes;
|
|
63
59
|
webhook_signing_secret: string;
|
|
60
|
+
constructor(settings: ApiSettings);
|
|
64
61
|
}
|
|
65
|
-
export {};
|
package/dist/mjs/rotacloud.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AccountsService, AttendanceService, AuthService, AvailabilityService, DailyBudgetsService, DailyRevenueService, DaysOffService, GroupsService, LeaveEmbargoesService, LeaveRequestService, LeaveService, LocationsService, RolesService, ShiftsService, UsersService } from './services/index.js';
|
|
1
|
+
import { AccountsService, AttendanceService, AuthService, AvailabilityService, DailyBudgetsService, DailyRevenueService, DaysOffService, GroupsService, LeaveEmbargoesService, LeaveRequestService, LeaveService, LocationsService, RolesService, SettingsService, ShiftsService, UsersService } from './services/index.js';
|
|
2
2
|
import { SDKConfig } from './interfaces/index.js';
|
|
3
3
|
export declare class RotaCloud {
|
|
4
4
|
static config: SDKConfig;
|
|
5
|
-
defaultAPIURI: string;
|
|
5
|
+
defaultAPIURI: string | undefined;
|
|
6
6
|
accounts: AccountsService;
|
|
7
7
|
attendance: AttendanceService;
|
|
8
8
|
auth: AuthService;
|
|
@@ -16,11 +16,13 @@ export declare class RotaCloud {
|
|
|
16
16
|
leave: LeaveService;
|
|
17
17
|
locations: LocationsService;
|
|
18
18
|
roles: RolesService;
|
|
19
|
+
settings: SettingsService;
|
|
19
20
|
shifts: ShiftsService;
|
|
20
21
|
users: UsersService;
|
|
21
22
|
constructor(config: SDKConfig);
|
|
22
23
|
get config(): SDKConfig;
|
|
23
24
|
set config(configVal: SDKConfig);
|
|
24
25
|
}
|
|
26
|
+
export { RetryStrategy, RetryOptions } from './services/service.js';
|
|
25
27
|
export * from './interfaces/index.js';
|
|
26
28
|
export * from './interfaces/query-params/index.js';
|
package/dist/mjs/rotacloud.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { AccountsService, AttendanceService, AuthService, AvailabilityService, DailyBudgetsService, DailyRevenueService, DaysOffService, GroupsService, LeaveEmbargoesService, LeaveRequestService, LeaveService, LocationsService, RolesService, ShiftsService, UsersService, } from './services/index.js';
|
|
1
|
+
import { AccountsService, AttendanceService, AuthService, AvailabilityService, DailyBudgetsService, DailyRevenueService, DaysOffService, GroupsService, LeaveEmbargoesService, LeaveRequestService, LeaveService, LocationsService, RetryStrategy, RolesService, SettingsService, ShiftsService, UsersService, } from './services/index.js';
|
|
2
|
+
const DEFAULT_CONFIG = {
|
|
3
|
+
baseUri: 'https://api.rotacloud.com/v1',
|
|
4
|
+
retry: RetryStrategy.Exponential,
|
|
5
|
+
};
|
|
2
6
|
export class RotaCloud {
|
|
3
7
|
constructor(config) {
|
|
4
|
-
this.defaultAPIURI =
|
|
8
|
+
this.defaultAPIURI = DEFAULT_CONFIG.baseUri;
|
|
5
9
|
this.accounts = new AccountsService();
|
|
6
10
|
this.attendance = new AttendanceService();
|
|
7
11
|
this.auth = new AuthService();
|
|
@@ -15,12 +19,13 @@ export class RotaCloud {
|
|
|
15
19
|
this.leave = new LeaveService();
|
|
16
20
|
this.locations = new LocationsService();
|
|
17
21
|
this.roles = new RolesService();
|
|
22
|
+
this.settings = new SettingsService();
|
|
18
23
|
this.shifts = new ShiftsService();
|
|
19
24
|
this.users = new UsersService();
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
this.config = {
|
|
26
|
+
...DEFAULT_CONFIG,
|
|
27
|
+
...config,
|
|
28
|
+
};
|
|
24
29
|
}
|
|
25
30
|
get config() {
|
|
26
31
|
return RotaCloud.config;
|
|
@@ -29,5 +34,6 @@ export class RotaCloud {
|
|
|
29
34
|
RotaCloud.config = configVal;
|
|
30
35
|
}
|
|
31
36
|
}
|
|
37
|
+
export { RetryStrategy } from './services/service.js';
|
|
32
38
|
export * from './interfaces/index.js';
|
|
33
39
|
export * from './interfaces/query-params/index.js';
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
1
2
|
import { Account } from '../models/account.model.js';
|
|
2
3
|
import { Service, Options } from './index.js';
|
|
3
4
|
import { ApiAccount } from '../interfaces/index.js';
|
|
4
5
|
declare class AccountsService extends Service {
|
|
5
6
|
private apiPath;
|
|
7
|
+
get(id: number): Promise<Account>;
|
|
8
|
+
get(id: number, options: {
|
|
9
|
+
rawResponse: true;
|
|
10
|
+
} & Options): Promise<AxiosResponse<ApiAccount, any>>;
|
|
11
|
+
get(id: number, options: Options): Promise<Account>;
|
|
6
12
|
list(options?: Options): AsyncGenerator<Account, void, unknown>;
|
|
7
13
|
listAll(options?: Options): Promise<Account[]>;
|
|
8
|
-
listByPage(options?: Options): AsyncGenerator<
|
|
14
|
+
listByPage(options?: Options): AsyncGenerator<AxiosResponse<ApiAccount[], any>, any, unknown>;
|
|
9
15
|
}
|
|
10
16
|
export { AccountsService };
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { Account } from '../models/account.model.js';
|
|
2
2
|
import { Service } from './index.js';
|
|
3
|
+
import { ErrorResponse } from '../models/error-response.model.js';
|
|
3
4
|
class AccountsService extends Service {
|
|
4
5
|
constructor() {
|
|
5
6
|
super(...arguments);
|
|
6
7
|
this.apiPath = '/accounts';
|
|
7
8
|
}
|
|
9
|
+
get(id, options) {
|
|
10
|
+
return super.fetch({ url: `${this.apiPath}/${id}` }, options).then((res) => Promise.resolve(options?.rawResponse ? res : new Account(res.data)), (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err)));
|
|
11
|
+
}
|
|
8
12
|
async *list(options) {
|
|
9
13
|
for await (const res of super.iterator({ url: this.apiPath }, options)) {
|
|
10
14
|
yield new Account(res);
|
|
@@ -12,5 +12,6 @@ export * from './leave-embargoes.service.js';
|
|
|
12
12
|
export * from './leave.service.js';
|
|
13
13
|
export * from './locations.service.js';
|
|
14
14
|
export * from './roles.service.js';
|
|
15
|
+
export * from './settings.service.js';
|
|
15
16
|
export * from './shifts.service.js';
|
|
16
17
|
export * from './users.service.js';
|
|
@@ -12,5 +12,6 @@ export * from './leave-embargoes.service.js';
|
|
|
12
12
|
export * from './leave.service.js';
|
|
13
13
|
export * from './locations.service.js';
|
|
14
14
|
export * from './roles.service.js';
|
|
15
|
+
export * from './settings.service.js';
|
|
15
16
|
export * from './shifts.service.js';
|
|
16
17
|
export * from './users.service.js';
|
|
@@ -1,5 +1,22 @@
|
|
|
1
|
-
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
1
|
+
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
2
|
export declare type RequirementsOf<T, K extends keyof T> = Required<Pick<T, K>> & Partial<T>;
|
|
3
|
+
export declare enum RetryStrategy {
|
|
4
|
+
Exponential = "expo",
|
|
5
|
+
Static = "static"
|
|
6
|
+
}
|
|
7
|
+
export declare type RetryOptions = {
|
|
8
|
+
/** Use exponential back-off */
|
|
9
|
+
exponential?: false;
|
|
10
|
+
/** The maximum number of retries before erroring */
|
|
11
|
+
maxRetries: number;
|
|
12
|
+
/** Delay in milliseconds between retry attempts - not used in exponential back-off */
|
|
13
|
+
delay: number;
|
|
14
|
+
} | {
|
|
15
|
+
/** Use exponential back-off */
|
|
16
|
+
exponential: true;
|
|
17
|
+
/** The maximum number of retries before erroring */
|
|
18
|
+
maxRetries: number;
|
|
19
|
+
};
|
|
3
20
|
export interface Options {
|
|
4
21
|
rawResponse?: boolean;
|
|
5
22
|
expand?: string[];
|
|
@@ -7,6 +24,7 @@ export interface Options {
|
|
|
7
24
|
limit?: number;
|
|
8
25
|
}
|
|
9
26
|
export declare abstract class Service<ApiResponse = any> {
|
|
27
|
+
protected client: AxiosInstance;
|
|
10
28
|
isLeaveRequest(endpoint?: string): boolean;
|
|
11
29
|
private buildQueryStr;
|
|
12
30
|
private getPagingObject;
|
|
@@ -1,8 +1,29 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
+
import axiosRetry from 'axios-retry';
|
|
2
3
|
import { RotaCloud } from '../rotacloud.js';
|
|
3
4
|
import { Version } from '../version.js';
|
|
5
|
+
export var RetryStrategy;
|
|
6
|
+
(function (RetryStrategy) {
|
|
7
|
+
RetryStrategy["Exponential"] = "expo";
|
|
8
|
+
RetryStrategy["Static"] = "static";
|
|
9
|
+
})(RetryStrategy || (RetryStrategy = {}));
|
|
10
|
+
const DEFAULT_RETRIES = 3;
|
|
11
|
+
const DEFAULT_RETRY_DELAY = 2000;
|
|
12
|
+
const DEFAULT_RETRY_STRATEGY_OPTIONS = {
|
|
13
|
+
[RetryStrategy.Exponential]: {
|
|
14
|
+
exponential: true,
|
|
15
|
+
maxRetries: DEFAULT_RETRIES,
|
|
16
|
+
},
|
|
17
|
+
[RetryStrategy.Static]: {
|
|
18
|
+
exponential: false,
|
|
19
|
+
maxRetries: DEFAULT_RETRIES,
|
|
20
|
+
delay: DEFAULT_RETRY_DELAY,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
4
23
|
export class Service {
|
|
5
|
-
|
|
24
|
+
constructor() {
|
|
25
|
+
this.client = axios.create();
|
|
26
|
+
}
|
|
6
27
|
isLeaveRequest(endpoint) {
|
|
7
28
|
return endpoint === '/leave_requests';
|
|
8
29
|
}
|
|
@@ -55,7 +76,21 @@ export class Service {
|
|
|
55
76
|
return params ? this.buildQueryStr(params) : '';
|
|
56
77
|
},
|
|
57
78
|
};
|
|
58
|
-
|
|
79
|
+
if (RotaCloud.config.retry) {
|
|
80
|
+
const retryConfig = typeof RotaCloud.config.retry === 'string'
|
|
81
|
+
? DEFAULT_RETRY_STRATEGY_OPTIONS[RotaCloud.config.retry]
|
|
82
|
+
: RotaCloud.config.retry;
|
|
83
|
+
axiosRetry(this.client, {
|
|
84
|
+
retries: retryConfig.maxRetries,
|
|
85
|
+
retryDelay: (retryCount) => {
|
|
86
|
+
if (retryConfig.exponential) {
|
|
87
|
+
return axiosRetry.exponentialDelay(retryCount);
|
|
88
|
+
}
|
|
89
|
+
return retryConfig.delay;
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const response = await this.client.request(reqObject);
|
|
59
94
|
return response;
|
|
60
95
|
}
|
|
61
96
|
async *listFetch(reqObject, options) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { Settings } from '../models/settings.model.js';
|
|
3
|
+
import { Service, Options } from './index.js';
|
|
4
|
+
import { ApiSettings } from '../interfaces/index.js';
|
|
5
|
+
import { SettingsQueryParams } from '../rotacloud.js';
|
|
6
|
+
declare class SettingsService extends Service {
|
|
7
|
+
private apiPath;
|
|
8
|
+
get(query: SettingsQueryParams): Promise<Settings>;
|
|
9
|
+
get(query: SettingsQueryParams, options: {
|
|
10
|
+
rawResponse: true;
|
|
11
|
+
} & Options): Promise<AxiosResponse<ApiSettings, any>>;
|
|
12
|
+
get(query: SettingsQueryParams, options: Options): Promise<Settings>;
|
|
13
|
+
}
|
|
14
|
+
export { SettingsService };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Settings } from '../models/settings.model.js';
|
|
2
|
+
import { Service } from './index.js';
|
|
3
|
+
import { ErrorResponse } from '../models/error-response.model.js';
|
|
4
|
+
class SettingsService extends Service {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.apiPath = '/settings';
|
|
8
|
+
}
|
|
9
|
+
get(query, options) {
|
|
10
|
+
return super.fetch({ url: `${this.apiPath}`, params: query }, options).then((res) => Promise.resolve(options?.rawResponse ? res : new Settings(res.data)), (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err)));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export { SettingsService };
|
package/dist/mjs/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const Version = { version: '1.0.
|
|
1
|
+
export const Version = { version: '1.0.31' };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rotacloud",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.31",
|
|
4
4
|
"description": "The RotaCloud SDK for the RotaCloud API",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=14.17.0"
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@types/node": "^16.11.6",
|
|
49
49
|
"axios": "^0.23.0",
|
|
50
|
+
"axios-retry": "^3.3.1",
|
|
50
51
|
"cross-var": "^1.1.0"
|
|
51
52
|
}
|
|
52
53
|
}
|
package/src/interfaces/index.ts
CHANGED
|
@@ -26,5 +26,6 @@ export * from './pay-period.interface.js';
|
|
|
26
26
|
export * from './role-rate.interface.js';
|
|
27
27
|
export * from './role.interface.js';
|
|
28
28
|
export * from './sdk-config.interface.js';
|
|
29
|
-
export * from './
|
|
29
|
+
export * from './settings.interface.js';
|
|
30
30
|
export * from './shift.interface.js';
|
|
31
|
+
export * from './user.interface.js';
|
|
@@ -17,6 +17,7 @@ export * from './locations-query-params.interface.js';
|
|
|
17
17
|
export * from './logbook-events-query-params.interface.js';
|
|
18
18
|
export * from './pay-periods-query-params.interface.js';
|
|
19
19
|
export * from './roles-query-params.interface.js';
|
|
20
|
+
export * from './settings-query-params.interface.js';
|
|
20
21
|
export * from './shifts-query-params.interface.js';
|
|
21
22
|
export * from './swap-requests-query-params.interface.js';
|
|
22
23
|
export * from './terminals-query-params.interface.js';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export interface PayCodes {
|
|
2
|
+
[pay_code_id: string]: string | { [leave_type_id: string]: string };
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface ApiSettings {
|
|
6
|
+
attendance_record_breaks: string;
|
|
7
|
+
automatically_clock_in_to_consecutive_shifts: boolean;
|
|
8
|
+
availability_employees_can_edit: boolean;
|
|
9
|
+
availability_managers_can_edit: boolean;
|
|
10
|
+
breaks_paid: boolean;
|
|
11
|
+
clock_in_out_reminders_minutes: number;
|
|
12
|
+
clock_in_without_shift_allowed: string;
|
|
13
|
+
currency_symbol: string;
|
|
14
|
+
dashboard_show_unpublished_shifts: boolean;
|
|
15
|
+
early_clock_ins_paid_from: string;
|
|
16
|
+
early_clock_in_minutes: number;
|
|
17
|
+
employee_shift_note_visibility: string;
|
|
18
|
+
employees_can_edit_timesheets: boolean;
|
|
19
|
+
employees_can_only_see_self: boolean;
|
|
20
|
+
employees_can_see_all_locations: boolean;
|
|
21
|
+
employees_can_see_everyones_leave: boolean;
|
|
22
|
+
flag_in_out_discrepancies_minutes: number;
|
|
23
|
+
holiday_accrual_rate: number;
|
|
24
|
+
late_clock_outs_paid_until: string;
|
|
25
|
+
lateness_added_after_minutes: number;
|
|
26
|
+
leave_can_request_over_allowance: boolean;
|
|
27
|
+
leave_prorate_allowances: boolean;
|
|
28
|
+
leave_requests_enabled: boolean;
|
|
29
|
+
leave_requests_notice_days: number;
|
|
30
|
+
leave_year_start_day: number;
|
|
31
|
+
leave_year_start_month: number;
|
|
32
|
+
metadata_enabled: boolean;
|
|
33
|
+
mobile_clocking_enabled: boolean;
|
|
34
|
+
no_show_notifications_minutes: number;
|
|
35
|
+
open_shift_claiming_enabled: boolean;
|
|
36
|
+
public_holiday_affects_allowance: boolean;
|
|
37
|
+
reminders_enabled: boolean;
|
|
38
|
+
rota_grouping: string;
|
|
39
|
+
rota_salaried_cost_method: string;
|
|
40
|
+
rota_show_employee_photos: boolean;
|
|
41
|
+
round_breaks: string;
|
|
42
|
+
round_breaks_direction: string;
|
|
43
|
+
round_currency: string;
|
|
44
|
+
round_currency_direction: string;
|
|
45
|
+
round_hours: string;
|
|
46
|
+
round_hours_direction: string;
|
|
47
|
+
shift_acknowledgement_enabled: boolean;
|
|
48
|
+
shift_swaps_across_locations_enabled: boolean;
|
|
49
|
+
shift_swaps_enabled: boolean;
|
|
50
|
+
shift_swaps_notice_hours: number;
|
|
51
|
+
shift_swaps_require_approval: boolean;
|
|
52
|
+
shift_swaps_shift_range_days: number;
|
|
53
|
+
show_open_shifts_from_other_locations: boolean;
|
|
54
|
+
show_shifts_from_other_locations: boolean;
|
|
55
|
+
time_format: string;
|
|
56
|
+
unavailability_notice_hours: number;
|
|
57
|
+
unavailability_requests_enabled: boolean;
|
|
58
|
+
unpaid_leave_types_included_in_accrual: number[];
|
|
59
|
+
paid_leave_types_included_in_accrual: number[];
|
|
60
|
+
week_starts: string;
|
|
61
|
+
pay_codes: PayCodes;
|
|
62
|
+
webhook_signing_secret: string;
|
|
63
|
+
}
|
|
@@ -1,13 +1,53 @@
|
|
|
1
|
-
import { ApiAttendance } from '../interfaces/index.js';
|
|
1
|
+
import { ApiAttendance, ApiAttendanceLocation, ApiShift } from '../interfaces/index.js';
|
|
2
2
|
|
|
3
3
|
export class Attendance {
|
|
4
4
|
public id: number;
|
|
5
|
+
public deleted: boolean;
|
|
5
6
|
public approved: boolean;
|
|
7
|
+
public in_time: number;
|
|
8
|
+
public out_time: number;
|
|
9
|
+
public minutes_break: number;
|
|
10
|
+
public user: number;
|
|
6
11
|
public location: number;
|
|
12
|
+
public role: number;
|
|
13
|
+
public minutes_late: number;
|
|
14
|
+
public hours: number;
|
|
15
|
+
public hours_auto: number;
|
|
16
|
+
public hours_is_auto: boolean;
|
|
17
|
+
public notes: string | null;
|
|
18
|
+
public shift: ApiShift | null;
|
|
19
|
+
public in_method: string;
|
|
20
|
+
public out_method: string;
|
|
21
|
+
public in_location: ApiAttendanceLocation;
|
|
22
|
+
public out_location: ApiAttendanceLocation;
|
|
23
|
+
public in_device: number;
|
|
24
|
+
public out_device: number;
|
|
25
|
+
public in_terminal: null;
|
|
26
|
+
public out_terminal: null;
|
|
7
27
|
|
|
8
28
|
constructor(attendance: ApiAttendance) {
|
|
9
29
|
this.id = attendance.id;
|
|
30
|
+
this.deleted = attendance.deleted;
|
|
10
31
|
this.approved = attendance.approved;
|
|
32
|
+
this.in_time = attendance.in_time;
|
|
33
|
+
this.out_time = attendance.out_time;
|
|
34
|
+
this.minutes_break = attendance.minutes_break;
|
|
35
|
+
this.user = attendance.user;
|
|
11
36
|
this.location = attendance.location;
|
|
37
|
+
this.role = attendance.role;
|
|
38
|
+
this.minutes_late = attendance.minutes_late;
|
|
39
|
+
this.hours = attendance.hours;
|
|
40
|
+
this.hours_auto = attendance.hours_auto;
|
|
41
|
+
this.hours_is_auto = attendance.hours_is_auto;
|
|
42
|
+
this.notes = attendance.notes;
|
|
43
|
+
this.shift = attendance.shift;
|
|
44
|
+
this.in_method = attendance.in_method;
|
|
45
|
+
this.out_method = attendance.out_method;
|
|
46
|
+
this.in_location = attendance.in_location;
|
|
47
|
+
this.out_location = attendance.out_location;
|
|
48
|
+
this.in_device = attendance.in_device;
|
|
49
|
+
this.out_device = attendance.out_device;
|
|
50
|
+
this.in_terminal = attendance.in_terminal;
|
|
51
|
+
this.out_terminal = attendance.out_terminal;
|
|
12
52
|
}
|
|
13
53
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
[pay_code_id: string]: string | { [leave_type_id: string]: string };
|
|
3
|
-
}
|
|
1
|
+
import { ApiSettings, PayCodes } from '../interfaces';
|
|
4
2
|
|
|
5
3
|
export class Settings {
|
|
6
4
|
public attendance_record_breaks: string;
|
|
@@ -60,4 +58,8 @@ export class Settings {
|
|
|
60
58
|
public week_starts: string;
|
|
61
59
|
public pay_codes: PayCodes;
|
|
62
60
|
public webhook_signing_secret: string;
|
|
61
|
+
|
|
62
|
+
constructor(settings: ApiSettings) {
|
|
63
|
+
this.attendance_record_breaks = settings.attendance_record_breaks;
|
|
64
|
+
}
|
|
63
65
|
}
|
package/src/rotacloud.ts
CHANGED
|
@@ -11,16 +11,23 @@ import {
|
|
|
11
11
|
LeaveRequestService,
|
|
12
12
|
LeaveService,
|
|
13
13
|
LocationsService,
|
|
14
|
+
RetryStrategy,
|
|
14
15
|
RolesService,
|
|
16
|
+
SettingsService,
|
|
15
17
|
ShiftsService,
|
|
16
18
|
UsersService,
|
|
17
19
|
} from './services/index.js';
|
|
18
20
|
import { SDKConfig } from './interfaces/index.js';
|
|
19
21
|
|
|
22
|
+
const DEFAULT_CONFIG: Partial<SDKConfig> = {
|
|
23
|
+
baseUri: 'https://api.rotacloud.com/v1',
|
|
24
|
+
retry: RetryStrategy.Exponential,
|
|
25
|
+
};
|
|
26
|
+
|
|
20
27
|
export class RotaCloud {
|
|
21
28
|
public static config: SDKConfig;
|
|
22
29
|
|
|
23
|
-
public defaultAPIURI =
|
|
30
|
+
public defaultAPIURI = DEFAULT_CONFIG.baseUri;
|
|
24
31
|
public accounts = new AccountsService();
|
|
25
32
|
public attendance = new AttendanceService();
|
|
26
33
|
public auth = new AuthService();
|
|
@@ -34,14 +41,15 @@ export class RotaCloud {
|
|
|
34
41
|
public leave = new LeaveService();
|
|
35
42
|
public locations = new LocationsService();
|
|
36
43
|
public roles = new RolesService();
|
|
44
|
+
public settings = new SettingsService();
|
|
37
45
|
public shifts = new ShiftsService();
|
|
38
46
|
public users = new UsersService();
|
|
39
47
|
|
|
40
48
|
constructor(config: SDKConfig) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
this.config = {
|
|
50
|
+
...DEFAULT_CONFIG,
|
|
51
|
+
...config,
|
|
52
|
+
};
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
get config() {
|
|
@@ -53,5 +61,6 @@ export class RotaCloud {
|
|
|
53
61
|
}
|
|
54
62
|
}
|
|
55
63
|
|
|
64
|
+
export { RetryStrategy, RetryOptions } from './services/service.js';
|
|
56
65
|
export * from './interfaces/index.js';
|
|
57
66
|
export * from './interfaces/query-params/index.js';
|
|
@@ -1,11 +1,23 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
1
2
|
import { Account } from '../models/account.model.js';
|
|
2
3
|
import { Service, Options } from './index.js';
|
|
3
4
|
|
|
4
5
|
import { ApiAccount } from '../interfaces/index.js';
|
|
6
|
+
import { ErrorResponse } from '../models/error-response.model.js';
|
|
5
7
|
|
|
6
8
|
class AccountsService extends Service {
|
|
7
9
|
private apiPath = '/accounts';
|
|
8
10
|
|
|
11
|
+
get(id: number): Promise<Account>;
|
|
12
|
+
get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiAccount, any>>;
|
|
13
|
+
get(id: number, options: Options): Promise<Account>;
|
|
14
|
+
get(id: number, options?: Options) {
|
|
15
|
+
return super.fetch<ApiAccount>({ url: `${this.apiPath}/${id}` }, options).then(
|
|
16
|
+
(res) => Promise.resolve(options?.rawResponse ? res : new Account(res.data)),
|
|
17
|
+
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
9
21
|
async *list(options?: Options) {
|
|
10
22
|
for await (const res of super.iterator<ApiAccount>({ url: this.apiPath }, options)) {
|
|
11
23
|
yield new Account(res);
|
package/src/services/index.ts
CHANGED
|
@@ -12,5 +12,6 @@ export * from './leave-embargoes.service.js';
|
|
|
12
12
|
export * from './leave.service.js';
|
|
13
13
|
export * from './locations.service.js';
|
|
14
14
|
export * from './roles.service.js';
|
|
15
|
+
export * from './settings.service.js';
|
|
15
16
|
export * from './shifts.service.js';
|
|
16
17
|
export * from './users.service.js';
|