rotacloud 1.0.25 → 1.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/dist/cjs/interfaces/auth.interface.d.ts +8 -0
  2. package/dist/cjs/interfaces/auth.interface.js +2 -0
  3. package/dist/cjs/interfaces/index.d.ts +1 -0
  4. package/dist/cjs/interfaces/index.js +1 -0
  5. package/dist/cjs/models/attendance.model.d.ts +21 -1
  6. package/dist/cjs/models/attendance.model.js +20 -0
  7. package/dist/cjs/models/auth.model.d.ts +6 -0
  8. package/dist/cjs/models/auth.model.js +10 -0
  9. package/dist/cjs/rotacloud.d.ts +3 -1
  10. package/dist/cjs/rotacloud.js +2 -0
  11. package/dist/cjs/services/accounts.service.d.ts +9 -4
  12. package/dist/cjs/services/accounts.service.js +6 -2
  13. package/dist/cjs/services/attendance.service.d.ts +13 -18
  14. package/dist/cjs/services/attendance.service.js +6 -6
  15. package/dist/cjs/services/auth.service.d.ts +11 -0
  16. package/dist/cjs/services/auth.service.js +16 -0
  17. package/dist/cjs/services/availability.service.d.ts +9 -16
  18. package/dist/cjs/services/availability.service.js +4 -4
  19. package/dist/cjs/services/daily-budgets.service.d.ts +8 -11
  20. package/dist/cjs/services/daily-budgets.service.js +9 -9
  21. package/dist/cjs/services/daily-revenue.service.d.ts +16 -0
  22. package/dist/cjs/services/daily-revenue.service.js +99 -0
  23. package/dist/cjs/services/days-off.service.d.ts +8 -12
  24. package/dist/cjs/services/days-off.service.js +6 -6
  25. package/dist/cjs/services/groups.service.d.ts +13 -18
  26. package/dist/cjs/services/groups.service.js +6 -6
  27. package/dist/cjs/services/index.d.ts +2 -0
  28. package/dist/cjs/services/index.js +2 -0
  29. package/dist/cjs/services/leave-embargoes.service.d.ts +13 -18
  30. package/dist/cjs/services/leave-embargoes.service.js +6 -6
  31. package/dist/cjs/services/leave-request.service.d.ts +12 -17
  32. package/dist/cjs/services/leave-request.service.js +4 -4
  33. package/dist/cjs/services/leave.service.d.ts +13 -18
  34. package/dist/cjs/services/leave.service.js +9 -9
  35. package/dist/cjs/services/locations.service.d.ts +13 -18
  36. package/dist/cjs/services/locations.service.js +6 -6
  37. package/dist/cjs/services/roles.service.d.ts +13 -18
  38. package/dist/cjs/services/roles.service.js +6 -6
  39. package/dist/cjs/services/service.d.ts +6 -4
  40. package/dist/cjs/services/service.js +2 -2
  41. package/dist/cjs/services/shifts.service.d.ts +19 -27
  42. package/dist/cjs/services/shifts.service.js +6 -6
  43. package/dist/cjs/services/users.service.d.ts +11 -16
  44. package/dist/cjs/services/users.service.js +6 -6
  45. package/dist/cjs/version.js +1 -1
  46. package/dist/mjs/interfaces/auth.interface.d.ts +8 -0
  47. package/dist/mjs/interfaces/auth.interface.js +1 -0
  48. package/dist/mjs/interfaces/index.d.ts +1 -0
  49. package/dist/mjs/interfaces/index.js +1 -0
  50. package/dist/mjs/models/attendance.model.d.ts +21 -1
  51. package/dist/mjs/models/attendance.model.js +20 -0
  52. package/dist/mjs/models/auth.model.d.ts +6 -0
  53. package/dist/mjs/models/auth.model.js +6 -0
  54. package/dist/mjs/rotacloud.d.ts +3 -1
  55. package/dist/mjs/rotacloud.js +3 -1
  56. package/dist/mjs/services/accounts.service.d.ts +9 -4
  57. package/dist/mjs/services/accounts.service.js +6 -2
  58. package/dist/mjs/services/attendance.service.d.ts +13 -18
  59. package/dist/mjs/services/attendance.service.js +7 -8
  60. package/dist/mjs/services/auth.service.d.ts +11 -0
  61. package/dist/mjs/services/auth.service.js +12 -0
  62. package/dist/mjs/services/availability.service.d.ts +9 -16
  63. package/dist/mjs/services/availability.service.js +4 -4
  64. package/dist/mjs/services/daily-budgets.service.d.ts +8 -11
  65. package/dist/mjs/services/daily-budgets.service.js +10 -11
  66. package/dist/mjs/services/daily-revenue.service.d.ts +16 -0
  67. package/dist/mjs/services/daily-revenue.service.js +38 -0
  68. package/dist/mjs/services/days-off.service.d.ts +8 -12
  69. package/dist/mjs/services/days-off.service.js +7 -8
  70. package/dist/mjs/services/groups.service.d.ts +13 -18
  71. package/dist/mjs/services/groups.service.js +7 -8
  72. package/dist/mjs/services/index.d.ts +2 -0
  73. package/dist/mjs/services/index.js +2 -0
  74. package/dist/mjs/services/leave-embargoes.service.d.ts +13 -18
  75. package/dist/mjs/services/leave-embargoes.service.js +7 -8
  76. package/dist/mjs/services/leave-request.service.d.ts +12 -17
  77. package/dist/mjs/services/leave-request.service.js +5 -6
  78. package/dist/mjs/services/leave.service.d.ts +13 -18
  79. package/dist/mjs/services/leave.service.js +10 -11
  80. package/dist/mjs/services/locations.service.d.ts +13 -18
  81. package/dist/mjs/services/locations.service.js +7 -8
  82. package/dist/mjs/services/roles.service.d.ts +13 -18
  83. package/dist/mjs/services/roles.service.js +7 -8
  84. package/dist/mjs/services/service.d.ts +6 -4
  85. package/dist/mjs/services/service.js +7 -2
  86. package/dist/mjs/services/shifts.service.d.ts +19 -27
  87. package/dist/mjs/services/shifts.service.js +7 -8
  88. package/dist/mjs/services/users.service.d.ts +11 -16
  89. package/dist/mjs/services/users.service.js +6 -6
  90. package/dist/mjs/version.js +1 -1
  91. package/package.json +1 -1
  92. package/src/interfaces/auth.interface.ts +9 -0
  93. package/src/interfaces/index.ts +1 -0
  94. package/src/models/attendance.model.ts +41 -1
  95. package/src/models/auth.model.ts +11 -0
  96. package/src/rotacloud.ts +4 -0
  97. package/src/services/accounts.service.ts +17 -6
  98. package/src/services/attendance.service.ts +20 -32
  99. package/src/services/auth.service.ts +19 -0
  100. package/src/services/availability.service.ts +14 -34
  101. package/src/services/daily-budgets.service.ts +15 -19
  102. package/src/services/daily-revenue.service.ts +53 -0
  103. package/src/services/days-off.service.ts +15 -21
  104. package/src/services/groups.service.ts +21 -23
  105. package/src/services/index.ts +2 -0
  106. package/src/services/leave-embargoes.service.ts +21 -30
  107. package/src/services/leave-request.service.ts +20 -31
  108. package/src/services/leave.service.ts +24 -29
  109. package/src/services/locations.service.ts +20 -26
  110. package/src/services/roles.service.ts +20 -24
  111. package/src/services/service.ts +18 -8
  112. package/src/services/shifts.service.ts +29 -41
  113. package/src/services/users.service.ts +19 -20
  114. package/src/version.ts +1 -1
@@ -1,23 +1,34 @@
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';
5
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
6
+ import { ErrorResponse } from '../models/error-response.model.js';
6
7
 
7
8
  class AccountsService extends Service {
8
9
  private apiPath = '/accounts';
9
10
 
10
- async *list(options?: Options<InternalQueryParams>) {
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
+
21
+ async *list(options?: Options) {
11
22
  for await (const res of super.iterator<ApiAccount>({ url: this.apiPath }, options)) {
12
23
  yield new Account(res);
13
24
  }
14
25
  }
15
26
 
16
- listAll(): Promise<Account[]>;
17
- async listAll() {
27
+ listAll(options?: Options): Promise<Account[]>;
28
+ async listAll(options?: Options) {
18
29
  try {
19
30
  const accounts = [] as Account[];
20
- for await (const account of this.list()) {
31
+ for await (const account of this.list(options)) {
21
32
  accounts.push(account);
22
33
  }
23
34
  return accounts;
@@ -26,7 +37,7 @@ class AccountsService extends Service {
26
37
  }
27
38
  }
28
39
 
29
- listByPage(options?: Options<InternalQueryParams>) {
40
+ listByPage(options?: Options) {
30
41
  return super.iterator<ApiAccount>({ url: this.apiPath }, options).byPage();
31
42
  }
32
43
  }
@@ -5,23 +5,19 @@ import { Service, Options, RequirementsOf } from './index.js';
5
5
  import { Attendance } from '../models/attendance.model.js';
6
6
  import { ErrorResponse } from '../models/error-response.model.js';
7
7
  import { AttendanceQueryParams } from '../interfaces/query-params/attendance-query-params.interface.js';
8
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
9
8
 
10
9
  type RequiredProps = 'user' | 'in_time';
11
10
 
12
- class AttendanceService extends Service {
11
+ export class AttendanceService extends Service {
13
12
  private apiPath = '/attendance';
14
13
 
15
14
  create(data: RequirementsOf<ApiAttendance, RequiredProps>): Promise<Attendance>;
16
15
  create(
17
16
  data: RequirementsOf<ApiAttendance, RequiredProps>,
18
- options: { rawResponse: true; params?: InternalQueryParams }
17
+ options: { rawResponse: true } & Options
19
18
  ): Promise<AxiosResponse<ApiAttendance, any>>;
20
- create(
21
- data: RequirementsOf<ApiAttendance, RequiredProps>,
22
- options: Options<InternalQueryParams>
23
- ): Promise<ApiAttendance>;
24
- create(data: RequirementsOf<ApiAttendance, RequiredProps>, options?: Options<InternalQueryParams>) {
19
+ create(data: RequirementsOf<ApiAttendance, RequiredProps>, options: Options): Promise<ApiAttendance>;
20
+ create(data: RequirementsOf<ApiAttendance, RequiredProps>, options?: Options) {
25
21
  return super.fetch<ApiAttendance>({ url: this.apiPath, data, method: 'POST' }).then(
26
22
  (res) => Promise.resolve(options?.rawResponse ? res : new Attendance(res.data)),
27
23
  (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
@@ -29,29 +25,26 @@ class AttendanceService extends Service {
29
25
  }
30
26
 
31
27
  get(id: number): Promise<Attendance>;
32
- get(
33
- id: number,
34
- options: { rawResponse: true; params?: InternalQueryParams }
35
- ): Promise<AxiosResponse<ApiAttendance, any>>;
36
- get(id: number, options: Options<InternalQueryParams>): Promise<ApiAttendance>;
37
- get(id: number, options?: Options<InternalQueryParams>) {
28
+ get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiAttendance, any>>;
29
+ get(id: number, options: Options): Promise<Attendance>;
30
+ get(id: number, options?: Options) {
38
31
  return super.fetch<ApiAttendance>({ url: `${this.apiPath}/${id}` }, options).then(
39
32
  (res) => Promise.resolve(options?.rawResponse ? res : new Attendance(res.data)),
40
33
  (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
41
34
  );
42
35
  }
43
36
 
44
- async *list(options?: Options<AttendanceQueryParams & InternalQueryParams>) {
45
- for await (const res of super.iterator<ApiAttendance>({ url: this.apiPath }, options)) {
37
+ async *list(query: AttendanceQueryParams, options?: Options) {
38
+ for await (const res of super.iterator<ApiAttendance>({ url: this.apiPath, params: query }, options)) {
46
39
  yield new Attendance(res);
47
40
  }
48
41
  }
49
42
 
50
- listAll(): Promise<Attendance[]>;
51
- async listAll() {
43
+ listAll(query: AttendanceQueryParams, options?: Options): Promise<Attendance[]>;
44
+ async listAll(query: AttendanceQueryParams, options?: Options) {
52
45
  try {
53
46
  const attendance = [] as Attendance[];
54
- for await (const atten of this.list()) {
47
+ for await (const atten of this.list(query, options)) {
55
48
  attendance.push(atten);
56
49
  }
57
50
  return attendance;
@@ -60,18 +53,18 @@ class AttendanceService extends Service {
60
53
  }
61
54
  }
62
55
 
63
- listByPage(options?: Options<AttendanceQueryParams & InternalQueryParams>) {
64
- return super.iterator<ApiAttendance>({ url: this.apiPath }, options).byPage();
56
+ listByPage(query: AttendanceQueryParams, options?: Options) {
57
+ return super.iterator<ApiAttendance>({ url: this.apiPath, params: query }, options).byPage();
65
58
  }
66
59
 
67
60
  update(id: number, data: Partial<ApiAttendance>): Promise<Attendance>;
68
61
  update(
69
62
  id: number,
70
63
  data: Partial<ApiAttendance>,
71
- options: { rawResponse: true; params?: InternalQueryParams }
64
+ options: { rawResponse: true } & Options
72
65
  ): Promise<AxiosResponse<ApiAttendance, any>>;
73
- update(id: number, data: Partial<ApiAttendance>, options: Options<InternalQueryParams>): Promise<Attendance>;
74
- update(id: number, data: Partial<ApiAttendance>, options?: Options<InternalQueryParams>) {
66
+ update(id: number, data: Partial<ApiAttendance>, options: Options): Promise<Attendance>;
67
+ update(id: number, data: Partial<ApiAttendance>, options?: Options) {
75
68
  return super
76
69
  .fetch<ApiAttendance>({
77
70
  url: `${this.apiPath}/${id}`,
@@ -85,17 +78,12 @@ class AttendanceService extends Service {
85
78
  }
86
79
 
87
80
  delete(id: number): Promise<number>;
88
- delete(
89
- id: number,
90
- options: { rawResponse: true; params?: InternalQueryParams }
91
- ): Promise<AxiosResponse<ApiAttendance, any>>;
92
- delete(id: number, options: Options<InternalQueryParams>): Promise<number>;
93
- delete(id: number, options?: Options<InternalQueryParams>) {
81
+ delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiAttendance, any>>;
82
+ delete(id: number, options: Options): Promise<number>;
83
+ delete(id: number, options?: Options) {
94
84
  return super.fetch<ApiAttendance>({ url: `${this.apiPath}/${id}`, method: 'DELETE' }).then(
95
85
  (res) => Promise.resolve(options?.rawResponse ? res : res.status),
96
86
  (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
97
87
  );
98
88
  }
99
89
  }
100
-
101
- export { AttendanceService };
@@ -0,0 +1,19 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { ApiAuth } from '../interfaces/index.js';
3
+ import { Service, Options } from './index.js';
4
+
5
+ import { Auth } from '../models/auth.model.js';
6
+ import { ErrorResponse } from '../models/error-response.model.js';
7
+
8
+ export class AuthService extends Service {
9
+ private apiPath = '/auth';
10
+
11
+ get(options?: { rawResponse: true } & Options): Promise<AxiosResponse<ApiAuth, any>>;
12
+ get(options?: Options): Promise<Auth>;
13
+ get(options?: Options) {
14
+ return super.fetch<ApiAuth>({ url: this.apiPath }, options).then(
15
+ (res) => Promise.resolve(options?.rawResponse ? res : new Auth(res.data)),
16
+ (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
17
+ );
18
+ }
19
+ }
@@ -1,28 +1,18 @@
1
1
  import { AxiosResponse } from 'axios';
2
- import { Service, Options, RequirementsOf } from './index.js';
2
+ import { Service, Options } from './index.js';
3
3
 
4
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
5
4
  import { AvailabilityQueryParams } from '../interfaces/query-params/availability-query-params.interface.js';
6
5
  import { Availability } from '../models/availability.model.js';
7
6
  import { ApiAvailability } from '../interfaces/availability.interface.js';
8
7
  import { ErrorResponse } from '../models/error-response.model.js';
9
8
 
10
- type RequiredProps = 'start' | 'end';
11
- type RequiredOptions<T> = RequirementsOf<Options<T>, 'params'>;
12
-
13
9
  export class AvailabilityService extends Service {
14
10
  private apiPath = '/availability';
15
11
 
16
12
  update(data: ApiAvailability): Promise<Availability>;
17
- update(
18
- data: ApiAvailability,
19
- options: { rawResponse: true; params?: InternalQueryParams }
20
- ): Promise<AxiosResponse<ApiAvailability>>;
21
- update(
22
- data: ApiAvailability,
23
- options?: Options<InternalQueryParams>
24
- ): Promise<Availability | AxiosResponse<ApiAvailability>>;
25
- update(data: ApiAvailability, options?: Options<InternalQueryParams>) {
13
+ update(data: ApiAvailability, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiAvailability>>;
14
+ update(data: ApiAvailability, options?: Options): Promise<Availability | AxiosResponse<ApiAvailability>>;
15
+ update(data: ApiAvailability, options?: Options) {
26
16
  return super
27
17
  .fetch<ApiAvailability>({
28
18
  url: this.apiPath,
@@ -37,15 +27,9 @@ export class AvailabilityService extends Service {
37
27
 
38
28
  /** Alias of {@link AvailabilityService["update"]} */
39
29
  create(data: ApiAvailability): Promise<Availability>;
40
- create(
41
- data: ApiAvailability,
42
- options: { rawResponse: true; params?: InternalQueryParams }
43
- ): Promise<AxiosResponse<ApiAvailability>>;
44
- create(
45
- data: ApiAvailability,
46
- options?: Options<InternalQueryParams>
47
- ): Promise<Availability | AxiosResponse<ApiAvailability>>;
48
- create(data: ApiAvailability, options?: Options<InternalQueryParams>) {
30
+ create(data: ApiAvailability, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiAvailability>>;
31
+ create(data: ApiAvailability, options?: Options): Promise<Availability | AxiosResponse<ApiAvailability>>;
32
+ create(data: ApiAvailability, options?: Options) {
49
33
  return this.update(data, options);
50
34
  }
51
35
 
@@ -53,14 +37,10 @@ export class AvailabilityService extends Service {
53
37
  delete(
54
38
  user: number,
55
39
  dates: string[],
56
- options: { rawResponse: true; params?: InternalQueryParams }
40
+ options: { rawResponse: true } & Options
57
41
  ): Promise<AxiosResponse<ApiAvailability>>;
58
- delete(
59
- user: number,
60
- dates: string[],
61
- options?: Options<InternalQueryParams>
62
- ): Promise<Availability | AxiosResponse<ApiAvailability>>;
63
- delete(user: number, dates: string[], options?: Options<InternalQueryParams>) {
42
+ delete(user: number, dates: string[], options?: Options): Promise<Availability | AxiosResponse<ApiAvailability>>;
43
+ delete(user: number, dates: string[], options?: Options) {
64
44
  return this.update(
65
45
  {
66
46
  user,
@@ -76,13 +56,13 @@ export class AvailabilityService extends Service {
76
56
  );
77
57
  }
78
58
 
79
- async *list(options: RequiredOptions<RequirementsOf<AvailabilityQueryParams, RequiredProps> & InternalQueryParams>) {
80
- for await (const res of super.iterator<ApiAvailability>({ url: this.apiPath }, options)) {
59
+ async *list(query: AvailabilityQueryParams, options?: Options) {
60
+ for await (const res of super.iterator<ApiAvailability>({ url: this.apiPath, params: query }, options)) {
81
61
  yield new Availability(res);
82
62
  }
83
63
  }
84
64
 
85
- listByPage(options: RequiredOptions<RequirementsOf<AvailabilityQueryParams, RequiredProps> & InternalQueryParams>) {
86
- return super.iterator<ApiAvailability>({ url: this.apiPath }, options).byPage();
65
+ listByPage(query: AvailabilityQueryParams, options?: Options) {
66
+ return super.iterator<ApiAvailability>({ url: this.apiPath, params: query }, options).byPage();
87
67
  }
88
68
  }
@@ -5,22 +5,21 @@ import { Service, Options } from './index.js';
5
5
  import { DailyBudgets } from '../models/daily-budgets.model.js';
6
6
  import { ErrorResponse } from '../models/error-response.model.js';
7
7
  import { DailyBudgetsQueryParams } from '../interfaces/query-params/daily-budgets-query-params.interface.js';
8
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
9
8
 
10
- class DailyBudgetsService extends Service {
9
+ export class DailyBudgetsService extends Service {
11
10
  private apiPath = '/daily_budgets';
12
11
 
13
- async *list(options?: Options<DailyBudgetsQueryParams & InternalQueryParams>) {
14
- for await (const res of super.iterator<ApiDailyBudgets>({ url: this.apiPath }, options)) {
12
+ async *list(query: DailyBudgetsQueryParams, options?: Options) {
13
+ for await (const res of super.iterator<ApiDailyBudgets>({ url: this.apiPath, params: query }, options)) {
15
14
  yield new DailyBudgets(res);
16
15
  }
17
16
  }
18
17
 
19
- listAll(): Promise<DailyBudgets[]>;
20
- async listAll() {
18
+ listAll(query: DailyBudgetsQueryParams, options?: Options): Promise<DailyBudgets[]>;
19
+ async listAll(query: DailyBudgetsQueryParams, options?: Options) {
21
20
  try {
22
21
  const attendance = [] as DailyBudgets[];
23
- for await (const atten of this.list()) {
22
+ for await (const atten of this.list(query, options)) {
24
23
  attendance.push(atten);
25
24
  }
26
25
  return attendance;
@@ -29,29 +28,26 @@ class DailyBudgetsService extends Service {
29
28
  }
30
29
  }
31
30
 
32
- listByPage(options?: Options<DailyBudgetsQueryParams & InternalQueryParams>) {
33
- return super.iterator<ApiDailyBudgets>({ url: this.apiPath }, options).byPage();
31
+ listByPage(query: DailyBudgetsQueryParams, options?: Options) {
32
+ return super.iterator<ApiDailyBudgets>({ url: this.apiPath, params: query }, options).byPage();
34
33
  }
35
34
 
36
- update(id: number, data: Partial<ApiDailyBudgets>): Promise<DailyBudgets>;
35
+ update(data: Partial<ApiDailyBudgets>[]): Promise<number>;
37
36
  update(
38
- id: number,
39
- data: Partial<ApiDailyBudgets>,
40
- options: { rawResponse: true; params?: InternalQueryParams }
37
+ data: Partial<ApiDailyBudgets>[],
38
+ options: { rawResponse: true } & Options
41
39
  ): Promise<AxiosResponse<ApiDailyBudgets, any>>;
42
- update(id: number, data: Partial<ApiDailyBudgets>, options: Options<InternalQueryParams>): Promise<ApiDailyBudgets>;
43
- update(id: number, data: Partial<ApiDailyBudgets>, options?: Options<InternalQueryParams>) {
40
+ update(data: Partial<ApiDailyBudgets>[], options: Options): Promise<number>;
41
+ update(data: Partial<ApiDailyBudgets>[], options?: Options) {
44
42
  return super
45
43
  .fetch<ApiDailyBudgets>({
46
- url: `${this.apiPath}/${id}`,
44
+ url: `${this.apiPath}`,
47
45
  data,
48
46
  method: 'POST',
49
47
  })
50
48
  .then(
51
- (res) => Promise.resolve(options?.rawResponse ? res : new DailyBudgets(res.data)),
49
+ (res) => Promise.resolve(options?.rawResponse ? res : res.status),
52
50
  (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
53
51
  );
54
52
  }
55
53
  }
56
-
57
- export { DailyBudgetsService };
@@ -0,0 +1,53 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { ApiDailyRevenue } from '../interfaces/daily-revenue.interface.js';
3
+ import { Service, Options } from './index.js';
4
+
5
+ import { DailyRevenue } from '../models/daily-revenue.model.js';
6
+ import { ErrorResponse } from '../models/error-response.model.js';
7
+ import { DailyRevenueQueryParams } from '../interfaces/query-params/daily-revenue-query-params.interface.js';
8
+
9
+ export class DailyRevenueService extends Service {
10
+ private apiPath = '/daily_revenue';
11
+
12
+ async *list(query: DailyRevenueQueryParams, options?: Options) {
13
+ for await (const res of super.iterator<ApiDailyRevenue>({ url: this.apiPath, params: query }, options)) {
14
+ yield new DailyRevenue(res);
15
+ }
16
+ }
17
+
18
+ listAll(query: DailyRevenueQueryParams, options?: Options): Promise<DailyRevenue[]>;
19
+ async listAll(query: DailyRevenueQueryParams, options?: Options) {
20
+ try {
21
+ const attendance = [] as DailyRevenue[];
22
+ for await (const atten of this.list(query, options)) {
23
+ attendance.push(atten);
24
+ }
25
+ return attendance;
26
+ } catch (err) {
27
+ return err;
28
+ }
29
+ }
30
+
31
+ listByPage(query: DailyRevenueQueryParams, options?: Options) {
32
+ return super.iterator<ApiDailyRevenue>({ url: this.apiPath, params: query }, options).byPage();
33
+ }
34
+
35
+ update(data: Partial<ApiDailyRevenue>[]): Promise<number>;
36
+ update(
37
+ data: Partial<ApiDailyRevenue>[],
38
+ options: { rawResponse: true } & Options
39
+ ): Promise<AxiosResponse<ApiDailyRevenue, any>>;
40
+ update(data: Partial<ApiDailyRevenue>[], options: Options): Promise<number>;
41
+ update(data: Partial<ApiDailyRevenue>[], options?: Options) {
42
+ return super
43
+ .fetch<ApiDailyRevenue>({
44
+ url: `${this.apiPath}`,
45
+ data,
46
+ method: 'POST',
47
+ })
48
+ .then(
49
+ (res) => Promise.resolve(options?.rawResponse ? res : res.status),
50
+ (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
51
+ );
52
+ }
53
+ }
@@ -3,21 +3,21 @@ import { ApiDaysOff } from '../interfaces/index.js';
3
3
  import { Service, Options } from './index.js';
4
4
 
5
5
  import { ErrorResponse } from '../models/error-response.model.js';
6
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
6
+
7
7
  import { DaysOff } from '../models/days-off.model.js';
8
8
  import { DaysOffQueryParams } from '../interfaces/query-params/days-off-query-params.interface.js';
9
9
 
10
- class DaysOffService extends Service<ApiDaysOff> {
10
+ export class DaysOffService extends Service<ApiDaysOff> {
11
11
  private apiPath = '/days_off';
12
12
 
13
13
  create(dates: string[], users: number[]): Promise<number>;
14
14
  create(
15
15
  dates: string[],
16
16
  users: number[],
17
- options: { rawResponse: true; params?: InternalQueryParams }
17
+ options: { rawResponse: true } & Options
18
18
  ): Promise<AxiosResponse<ApiDaysOff, any>>;
19
- create(dates: string[], users: number[], options: Options<InternalQueryParams>): Promise<number>;
20
- create(dates: string[], users: number[], options?: Options<InternalQueryParams>) {
19
+ create(dates: string[], users: number[], options: Options): Promise<number>;
20
+ create(dates: string[], users: number[], options?: Options) {
21
21
  return super
22
22
  .fetch({
23
23
  url: this.apiPath,
@@ -33,17 +33,17 @@ class DaysOffService extends Service<ApiDaysOff> {
33
33
  );
34
34
  }
35
35
 
36
- async *list(options?: Options<DaysOffQueryParams & InternalQueryParams>) {
37
- for await (const res of super.iterator({ url: this.apiPath }, options)) {
36
+ async *list(query: DaysOffQueryParams, options?: Options) {
37
+ for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
38
38
  yield new DaysOff(res);
39
39
  }
40
40
  }
41
41
 
42
- listAll(): Promise<DaysOff[]>;
43
- async listAll() {
42
+ listAll(query: DaysOffQueryParams, options?: Options): Promise<DaysOff[]>;
43
+ async listAll(query: DaysOffQueryParams, options?: Options) {
44
44
  try {
45
45
  const daysOff = [] as DaysOff[];
46
- for await (const dayOff of this.list()) {
46
+ for await (const dayOff of this.list(query, options)) {
47
47
  daysOff.push(dayOff);
48
48
  }
49
49
  return daysOff;
@@ -52,18 +52,14 @@ class DaysOffService extends Service<ApiDaysOff> {
52
52
  }
53
53
  }
54
54
 
55
- listByPage(options?: Options<DaysOffQueryParams & InternalQueryParams>) {
56
- return super.iterator({ url: this.apiPath }, options).byPage();
55
+ listByPage(query: DaysOffQueryParams, options?: Options) {
56
+ return super.iterator({ url: this.apiPath, params: query }, options).byPage();
57
57
  }
58
58
 
59
59
  delete(dates: string[], users: number[]): Promise<number>;
60
- delete(
61
- dates: string[],
62
- users: number[],
63
- options: { rawResponse: true; params?: InternalQueryParams }
64
- ): Promise<AxiosResponse<any, any>>;
65
- delete(dates: string[], users: number[], options: Options<InternalQueryParams>): Promise<number>;
66
- delete(dates: string[], users: number[], options?: Options<InternalQueryParams>) {
60
+ delete(dates: string[], users: number[], options: { rawResponse: true } & Options): Promise<AxiosResponse<any, any>>;
61
+ delete(dates: string[], users: number[], options: Options): Promise<number>;
62
+ delete(dates: string[], users: number[], options?: Options) {
67
63
  return super
68
64
  .fetch({
69
65
  url: this.apiPath,
@@ -79,5 +75,3 @@ class DaysOffService extends Service<ApiDaysOff> {
79
75
  );
80
76
  }
81
77
  }
82
-
83
- export { DaysOffService };
@@ -3,22 +3,22 @@ import { ApiGroup } from '../interfaces/index.js';
3
3
  import { Service, Options, RequirementsOf } from './index.js';
4
4
 
5
5
  import { ErrorResponse } from '../models/error-response.model.js';
6
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
6
+
7
7
  import { Group } from '../models/group.model.js';
8
8
  import { GroupsQueryParams } from '../interfaces/query-params/groups-query-params.interface.js';
9
9
 
10
10
  type RequiredProps = 'name';
11
11
 
12
- class GroupsService extends Service {
12
+ export class GroupsService extends Service {
13
13
  private apiPath = '/groups';
14
14
 
15
15
  create(data: RequirementsOf<ApiGroup, RequiredProps>): Promise<Group>;
16
16
  create(
17
17
  data: RequirementsOf<ApiGroup, RequiredProps>,
18
- options: { rawResponse: true; params?: InternalQueryParams }
18
+ options: { rawResponse: true } & Options
19
19
  ): Promise<AxiosResponse<ApiGroup, any>>;
20
- create(data: RequirementsOf<ApiGroup, RequiredProps>, options: Options<InternalQueryParams>): Promise<Group>;
21
- create(data: RequirementsOf<ApiGroup, RequiredProps>, options?: Options<InternalQueryParams>) {
20
+ create(data: RequirementsOf<ApiGroup, RequiredProps>, options: Options): Promise<Group>;
21
+ create(data: RequirementsOf<ApiGroup, RequiredProps>, options?: Options) {
22
22
  return super.fetch<ApiGroup>({ url: this.apiPath, data, method: 'POST' }).then(
23
23
  (res) => Promise.resolve(options?.rawResponse ? res : new Group(res.data)),
24
24
  (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
@@ -26,26 +26,26 @@ class GroupsService extends Service {
26
26
  }
27
27
 
28
28
  get(id: number): Promise<Group>;
29
- get(id: number, options: { rawResponse: true; params?: InternalQueryParams }): Promise<AxiosResponse<ApiGroup, any>>;
30
- get(id: number, options: Options<InternalQueryParams>): Promise<Group>;
31
- get(id: number, options?: Options<InternalQueryParams>) {
29
+ get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiGroup, any>>;
30
+ get(id: number, options: Options): Promise<Group>;
31
+ get(id: number, options?: Options) {
32
32
  return super.fetch<ApiGroup>({ url: `${this.apiPath}/${id}` }, options).then(
33
33
  (res) => Promise.resolve(options?.rawResponse ? res : new Group(res.data)),
34
34
  (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
35
35
  );
36
36
  }
37
37
 
38
- async *list(options?: Options<GroupsQueryParams & InternalQueryParams>) {
39
- for await (const res of super.iterator<ApiGroup>({ url: this.apiPath }, options)) {
38
+ async *list(query: GroupsQueryParams, options?: Options) {
39
+ for await (const res of super.iterator<ApiGroup>({ url: this.apiPath, params: query }, options)) {
40
40
  yield new Group(res);
41
41
  }
42
42
  }
43
43
 
44
- listAll(): Promise<Group[]>;
45
- async listAll() {
44
+ listAll(query: GroupsQueryParams, options?: Options): Promise<Group[]>;
45
+ async listAll(query: GroupsQueryParams, options?: Options) {
46
46
  try {
47
47
  const groups = [] as Group[];
48
- for await (const group of this.list()) {
48
+ for await (const group of this.list(query, options)) {
49
49
  groups.push(group);
50
50
  }
51
51
  return groups;
@@ -54,18 +54,18 @@ class GroupsService extends Service {
54
54
  }
55
55
  }
56
56
 
57
- listByPage(options?: Options<GroupsQueryParams & InternalQueryParams>) {
58
- return super.iterator<ApiGroup>({ url: this.apiPath }, options).byPage();
57
+ listByPage(query: GroupsQueryParams, options?: Options) {
58
+ return super.iterator<ApiGroup>({ url: this.apiPath, params: query }, options).byPage();
59
59
  }
60
60
 
61
61
  update(id: number, data: Partial<ApiGroup>): Promise<Group>;
62
62
  update(
63
63
  id: number,
64
64
  data: Partial<ApiGroup>,
65
- options: { rawResponse: true; params?: InternalQueryParams }
65
+ options: { rawResponse: true } & Options
66
66
  ): Promise<AxiosResponse<ApiGroup, any>>;
67
- update(id: number, data: Partial<ApiGroup>, options: Options<InternalQueryParams>): Promise<Group>;
68
- update(id: number, data: Partial<ApiGroup>, options?: Options<InternalQueryParams>) {
67
+ update(id: number, data: Partial<ApiGroup>, options: Options): Promise<Group>;
68
+ update(id: number, data: Partial<ApiGroup>, options?: Options) {
69
69
  return super
70
70
  .fetch<ApiGroup>({
71
71
  url: `${this.apiPath}/${id}`,
@@ -79,14 +79,12 @@ class GroupsService extends Service {
79
79
  }
80
80
 
81
81
  delete(id: number): Promise<number>;
82
- delete(id: number, options: { rawResponse: true; params?: InternalQueryParams }): Promise<AxiosResponse<any, any>>;
83
- delete(id: number, options: Options<InternalQueryParams>): Promise<number>;
84
- delete(id: number, options?: Options<InternalQueryParams>) {
82
+ delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<any, any>>;
83
+ delete(id: number, options: Options): Promise<number>;
84
+ delete(id: number, options?: Options) {
85
85
  return super.fetch<ApiGroup>({ url: `${this.apiPath}/${id}`, method: 'DELETE' }).then(
86
86
  (res) => Promise.resolve(options?.rawResponse ? res : res.status),
87
87
  (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
88
88
  );
89
89
  }
90
90
  }
91
-
92
- export { GroupsService };
@@ -1,8 +1,10 @@
1
1
  export * from './service.js';
2
2
  export * from './accounts.service.js';
3
3
  export * from './attendance.service.js';
4
+ export * from './auth.service.js';
4
5
  export * from './availability.service.js';
5
6
  export * from './daily-budgets.service.js';
7
+ export * from './daily-revenue.service.js';
6
8
  export * from './days-off.service.js';
7
9
  export * from './groups.service.js';
8
10
  export * from './leave-request.service.js';