rotacloud 1.0.4 → 1.0.5
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 +1 -1
- package/dist/rotacloud.d.ts +1 -1
- package/dist/rotacloud.js +3 -3
- package/dist/services/service.js +6 -7
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/rotacloud.ts +3 -3
- package/src/services/service.ts +6 -6
- package/src/version.ts +1 -1
package/README.md
CHANGED
package/dist/rotacloud.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AccountsService, AttendanceService, LeaveEmbargoesService, LeaveRequestService, LeaveService, LocationsService, RolesService, ShiftsService, UsersService } from './services/index.js';
|
|
2
2
|
import { SDKConfig } from './interfaces/index.js';
|
|
3
3
|
import { DaysOffService } from './services/days-off.service.js';
|
|
4
|
-
export declare class
|
|
4
|
+
export declare class RotaCloud {
|
|
5
5
|
static config: SDKConfig;
|
|
6
6
|
defaultAPIURI: string;
|
|
7
7
|
accounts: AccountsService;
|
package/dist/rotacloud.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AccountsService, AttendanceService, LeaveEmbargoesService, LeaveRequestService, LeaveService, LocationsService, RolesService, ShiftsService, UsersService, } from './services/index.js';
|
|
2
2
|
import { DaysOffService } from './services/days-off.service.js';
|
|
3
|
-
export class
|
|
3
|
+
export class RotaCloud {
|
|
4
4
|
constructor(config) {
|
|
5
5
|
this.defaultAPIURI = 'https://api.rotacloud.com/v1';
|
|
6
6
|
this.accounts = new AccountsService();
|
|
@@ -19,9 +19,9 @@ export class Rotacloud {
|
|
|
19
19
|
this.config = config;
|
|
20
20
|
}
|
|
21
21
|
get config() {
|
|
22
|
-
return
|
|
22
|
+
return RotaCloud.config;
|
|
23
23
|
}
|
|
24
24
|
set config(configVal) {
|
|
25
|
-
|
|
25
|
+
RotaCloud.config = configVal;
|
|
26
26
|
}
|
|
27
27
|
}
|
package/dist/services/service.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import {
|
|
3
|
-
import { Version } from '../version.js';
|
|
2
|
+
import { RotaCloud } from '../rotacloud.js';
|
|
4
3
|
export class Service {
|
|
5
4
|
// rate limit tracking could be implemented here statically
|
|
6
5
|
isLeaveRequest(endpoint) {
|
|
@@ -31,11 +30,11 @@ export class Service {
|
|
|
31
30
|
}
|
|
32
31
|
async fetch(httpOptions, options) {
|
|
33
32
|
const headers = {
|
|
34
|
-
Authorization: `Bearer ${
|
|
35
|
-
'SDK-Version': Version.version,
|
|
33
|
+
Authorization: `Bearer ${RotaCloud.config.apiKey}`,
|
|
34
|
+
// 'SDK-Version': Version.version,
|
|
36
35
|
};
|
|
37
|
-
if (
|
|
38
|
-
headers.Account = String(
|
|
36
|
+
if (RotaCloud.config.accountId) {
|
|
37
|
+
headers.Account = String(RotaCloud.config.accountId);
|
|
39
38
|
}
|
|
40
39
|
else {
|
|
41
40
|
// need to convert user field in payload to a header for creating leave_requests when using an API key
|
|
@@ -43,7 +42,7 @@ export class Service {
|
|
|
43
42
|
}
|
|
44
43
|
const reqObject = {
|
|
45
44
|
...httpOptions,
|
|
46
|
-
baseURL:
|
|
45
|
+
baseURL: RotaCloud.config.baseUri,
|
|
47
46
|
headers,
|
|
48
47
|
params: options?.params,
|
|
49
48
|
paramsSerializer: (params) => {
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const Version = { version: "1.0.
|
|
1
|
+
export const Version = { version: "1.0.5" };
|
package/package.json
CHANGED
package/src/rotacloud.ts
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import { SDKConfig } from './interfaces/index.js';
|
|
13
13
|
import { DaysOffService } from './services/days-off.service.js';
|
|
14
14
|
|
|
15
|
-
export class
|
|
15
|
+
export class RotaCloud {
|
|
16
16
|
public static config: SDKConfig;
|
|
17
17
|
|
|
18
18
|
public defaultAPIURI = 'https://api.rotacloud.com/v1';
|
|
@@ -35,10 +35,10 @@ export class Rotacloud {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
get config() {
|
|
38
|
-
return
|
|
38
|
+
return RotaCloud.config;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
set config(configVal: SDKConfig) {
|
|
42
|
-
|
|
42
|
+
RotaCloud.config = configVal;
|
|
43
43
|
}
|
|
44
44
|
}
|
package/src/services/service.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import axios, { AxiosRequestConfig, AxiosRequestHeaders, AxiosResponse } from 'axios';
|
|
2
|
-
import {
|
|
2
|
+
import { RotaCloud } from '../rotacloud.js';
|
|
3
3
|
import { Version } from '../version.js';
|
|
4
4
|
|
|
5
5
|
export type RequirementsOf<T, K extends keyof T> = Required<Pick<T, K>> & Partial<T>;
|
|
@@ -53,11 +53,11 @@ export abstract class Service<ApiResponse = any> {
|
|
|
53
53
|
|
|
54
54
|
public async fetch<T = ApiResponse>(httpOptions: AxiosRequestConfig, options?): Promise<AxiosResponse<T>> {
|
|
55
55
|
const headers: AxiosRequestHeaders = {
|
|
56
|
-
Authorization: `Bearer ${
|
|
57
|
-
'SDK-Version': Version.version,
|
|
56
|
+
Authorization: `Bearer ${RotaCloud.config.apiKey}`,
|
|
57
|
+
// 'SDK-Version': Version.version,
|
|
58
58
|
};
|
|
59
|
-
if (
|
|
60
|
-
headers.Account = String(
|
|
59
|
+
if (RotaCloud.config.accountId) {
|
|
60
|
+
headers.Account = String(RotaCloud.config.accountId);
|
|
61
61
|
} else {
|
|
62
62
|
// need to convert user field in payload to a header for creating leave_requests when using an API key
|
|
63
63
|
this.isLeaveRequest(httpOptions.url) ? (headers.User = `${httpOptions.data.user}`) : undefined;
|
|
@@ -65,7 +65,7 @@ export abstract class Service<ApiResponse = any> {
|
|
|
65
65
|
|
|
66
66
|
const reqObject: AxiosRequestConfig<T> = {
|
|
67
67
|
...httpOptions,
|
|
68
|
-
baseURL:
|
|
68
|
+
baseURL: RotaCloud.config.baseUri,
|
|
69
69
|
headers,
|
|
70
70
|
params: options?.params,
|
|
71
71
|
paramsSerializer: (params) => {
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const Version = { version: "1.0.
|
|
1
|
+
export const Version = { version: "1.0.5" }
|