pha-hermes 1.27.0 → 1.29.0
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/api/liphe_legacy/lipheApiClient.d.ts +2 -0
- package/dist/api/liphe_legacy/timesheets/timesheetClient.d.ts +36 -0
- package/dist/api/salesforce/accounts/accounts.d.ts +2 -1
- package/dist/pha-hermes.cjs.development.js +157 -8
- package/dist/pha-hermes.cjs.development.js.map +1 -1
- package/dist/pha-hermes.cjs.production.min.js +1 -1
- package/dist/pha-hermes.cjs.production.min.js.map +1 -1
- package/dist/pha-hermes.esm.js +157 -8
- package/dist/pha-hermes.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/api/liphe_legacy/auth/authClient.ts +10 -1
- package/src/api/liphe_legacy/lipheApiClient.ts +3 -0
- package/src/api/liphe_legacy/timesheets/timesheetClient.ts +101 -0
- package/src/api/salesforce/accounts/accounts.ts +20 -9
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
2
|
import { LiphePractitionerClient } from './practitioner/practitionerClient';
|
|
3
3
|
import { ContractRequestPeriodClient } from './contract_request_period/contractRequestPeriodClient';
|
|
4
|
+
import { TimesheetClient } from './timesheets/timesheetClient';
|
|
4
5
|
export declare class LipheApiClient {
|
|
5
6
|
private instance;
|
|
6
7
|
private axiosInstance;
|
|
7
8
|
private authenticator;
|
|
8
9
|
practitionerClient: LiphePractitionerClient;
|
|
9
10
|
contractRequestPeriodClient: ContractRequestPeriodClient;
|
|
11
|
+
timesheetClient: TimesheetClient;
|
|
10
12
|
constructor(baseUrl: string, email: string, password: string, type?: 'user' | 'client');
|
|
11
13
|
init(): Promise<void>;
|
|
12
14
|
setInstance(instance: LipheApiClient): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AxiosInstance } from 'axios';
|
|
2
|
+
export interface TimesheetParams {
|
|
3
|
+
workorder_id: string;
|
|
4
|
+
start: Date;
|
|
5
|
+
end: Date;
|
|
6
|
+
}
|
|
7
|
+
export interface CallbackTimesheetParams extends TimesheetParams {
|
|
8
|
+
reason: string;
|
|
9
|
+
}
|
|
10
|
+
export interface StandbyTimesheetParams extends TimesheetParams {
|
|
11
|
+
calls_order: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const TimesheetType: {
|
|
14
|
+
readonly Regular: "regular";
|
|
15
|
+
readonly Callback: "callback";
|
|
16
|
+
readonly Overtime: "overtime";
|
|
17
|
+
readonly Standby: "standby";
|
|
18
|
+
};
|
|
19
|
+
export interface TimesheetResponse {
|
|
20
|
+
success: boolean;
|
|
21
|
+
data?: any;
|
|
22
|
+
error?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare class TimesheetClient {
|
|
25
|
+
private axios;
|
|
26
|
+
constructor(axiosInstance: AxiosInstance);
|
|
27
|
+
sendRegularTimesheet(params: TimesheetParams): Promise<TimesheetResponse>;
|
|
28
|
+
sendCallbackTimesheet(params: CallbackTimesheetParams): Promise<TimesheetResponse>;
|
|
29
|
+
sendOvertimeTimesheet(params: TimesheetParams): Promise<TimesheetResponse>;
|
|
30
|
+
sendStandbyTimesheet(params: StandbyTimesheetParams): Promise<TimesheetResponse>;
|
|
31
|
+
private sendTimesheet;
|
|
32
|
+
/**
|
|
33
|
+
* Converts a Date object to the required string format: "YYYY-MM-DD HH:mm"
|
|
34
|
+
*/
|
|
35
|
+
private formatDateTime;
|
|
36
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxiosInstance } from
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
2
|
export interface Account {
|
|
3
3
|
id: string;
|
|
4
4
|
name: string;
|
|
@@ -15,6 +15,7 @@ export interface Account {
|
|
|
15
15
|
fax: string | null;
|
|
16
16
|
email: string;
|
|
17
17
|
lang: 'eng' | 'fra';
|
|
18
|
+
clientNumber: string;
|
|
18
19
|
}
|
|
19
20
|
export interface HealthAuthority extends Account {
|
|
20
21
|
accountTypeName: 'healthAuthority';
|
|
@@ -1375,7 +1375,7 @@ var SFPriceClient = /*#__PURE__*/function () {
|
|
|
1375
1375
|
return SFPriceClient;
|
|
1376
1376
|
}();
|
|
1377
1377
|
|
|
1378
|
-
var ACCOUNT_FIELDS = ['Id', 'Name', 'BillingCity', 'BillingState', 'BillingPostalCode', 'BillingCountry', 'BillingAddress', 'Phone', 'Fax', 'Type'];
|
|
1378
|
+
var ACCOUNT_FIELDS = ['Id', 'Name', 'BillingCity', 'BillingState', 'BillingPostalCode', 'BillingCountry', 'BillingAddress', 'Phone', 'Fax', 'Type', 'Client_Number__c'];
|
|
1379
1379
|
var SFAccounts = /*#__PURE__*/function () {
|
|
1380
1380
|
function SFAccounts(axiosInstance) {
|
|
1381
1381
|
this.axiosInstance = axiosInstance;
|
|
@@ -1503,7 +1503,8 @@ var SFAccounts = /*#__PURE__*/function () {
|
|
|
1503
1503
|
email: null,
|
|
1504
1504
|
phone2: null,
|
|
1505
1505
|
cellular: null,
|
|
1506
|
-
lang: 'eng'
|
|
1506
|
+
lang: 'eng',
|
|
1507
|
+
clientNumber: record.Client_Number__c
|
|
1507
1508
|
};
|
|
1508
1509
|
};
|
|
1509
1510
|
return SFAccounts;
|
|
@@ -1688,8 +1689,8 @@ var LipheAuthenticator = /*#__PURE__*/function () {
|
|
|
1688
1689
|
}();
|
|
1689
1690
|
_proto.login = /*#__PURE__*/function () {
|
|
1690
1691
|
var _login = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
1691
|
-
var
|
|
1692
|
-
var form, response, token;
|
|
1692
|
+
var _responseData;
|
|
1693
|
+
var form, response, responseData, jsonMatch, token;
|
|
1693
1694
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1694
1695
|
while (1) switch (_context3.prev = _context3.next) {
|
|
1695
1696
|
case 0:
|
|
@@ -1703,16 +1704,23 @@ var LipheAuthenticator = /*#__PURE__*/function () {
|
|
|
1703
1704
|
});
|
|
1704
1705
|
case 6:
|
|
1705
1706
|
response = _context3.sent;
|
|
1706
|
-
|
|
1707
|
+
responseData = response.data;
|
|
1708
|
+
if (typeof responseData === 'string') {
|
|
1709
|
+
jsonMatch = responseData.match(/^\{.*?}(?=HTTP|$)/);
|
|
1710
|
+
if (jsonMatch) {
|
|
1711
|
+
responseData = JSON.parse(jsonMatch[0]);
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
token = (_responseData = responseData) == null || (_responseData = _responseData.data) == null ? void 0 : _responseData.token;
|
|
1707
1715
|
if (token) {
|
|
1708
|
-
_context3.next =
|
|
1716
|
+
_context3.next = 12;
|
|
1709
1717
|
break;
|
|
1710
1718
|
}
|
|
1711
1719
|
throw new Error('Authentication failed: no token return');
|
|
1712
|
-
case
|
|
1720
|
+
case 12:
|
|
1713
1721
|
this.token = token;
|
|
1714
1722
|
return _context3.abrupt("return", token);
|
|
1715
|
-
case
|
|
1723
|
+
case 14:
|
|
1716
1724
|
case "end":
|
|
1717
1725
|
return _context3.stop();
|
|
1718
1726
|
}
|
|
@@ -1996,6 +2004,146 @@ var ContractRequestPeriodClient = /*#__PURE__*/function () {
|
|
|
1996
2004
|
return ContractRequestPeriodClient;
|
|
1997
2005
|
}();
|
|
1998
2006
|
|
|
2007
|
+
var TimesheetType = {
|
|
2008
|
+
Regular: 'regular',
|
|
2009
|
+
Callback: 'callback',
|
|
2010
|
+
Overtime: 'overtime',
|
|
2011
|
+
Standby: 'standby'
|
|
2012
|
+
};
|
|
2013
|
+
var TimesheetClient = /*#__PURE__*/function () {
|
|
2014
|
+
function TimesheetClient(axiosInstance) {
|
|
2015
|
+
this.axios = axiosInstance;
|
|
2016
|
+
}
|
|
2017
|
+
var _proto = TimesheetClient.prototype;
|
|
2018
|
+
_proto.sendRegularTimesheet = /*#__PURE__*/function () {
|
|
2019
|
+
var _sendRegularTimesheet = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
|
|
2020
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2021
|
+
while (1) switch (_context.prev = _context.next) {
|
|
2022
|
+
case 0:
|
|
2023
|
+
return _context.abrupt("return", this.sendTimesheet(TimesheetType.Regular, params));
|
|
2024
|
+
case 1:
|
|
2025
|
+
case "end":
|
|
2026
|
+
return _context.stop();
|
|
2027
|
+
}
|
|
2028
|
+
}, _callee, this);
|
|
2029
|
+
}));
|
|
2030
|
+
function sendRegularTimesheet(_x) {
|
|
2031
|
+
return _sendRegularTimesheet.apply(this, arguments);
|
|
2032
|
+
}
|
|
2033
|
+
return sendRegularTimesheet;
|
|
2034
|
+
}();
|
|
2035
|
+
_proto.sendCallbackTimesheet = /*#__PURE__*/function () {
|
|
2036
|
+
var _sendCallbackTimesheet = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
2037
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
2038
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
2039
|
+
case 0:
|
|
2040
|
+
return _context2.abrupt("return", this.sendTimesheet(TimesheetType.Callback, params));
|
|
2041
|
+
case 1:
|
|
2042
|
+
case "end":
|
|
2043
|
+
return _context2.stop();
|
|
2044
|
+
}
|
|
2045
|
+
}, _callee2, this);
|
|
2046
|
+
}));
|
|
2047
|
+
function sendCallbackTimesheet(_x2) {
|
|
2048
|
+
return _sendCallbackTimesheet.apply(this, arguments);
|
|
2049
|
+
}
|
|
2050
|
+
return sendCallbackTimesheet;
|
|
2051
|
+
}();
|
|
2052
|
+
_proto.sendOvertimeTimesheet = /*#__PURE__*/function () {
|
|
2053
|
+
var _sendOvertimeTimesheet = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
2054
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
2055
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
2056
|
+
case 0:
|
|
2057
|
+
return _context3.abrupt("return", this.sendTimesheet(TimesheetType.Overtime, params));
|
|
2058
|
+
case 1:
|
|
2059
|
+
case "end":
|
|
2060
|
+
return _context3.stop();
|
|
2061
|
+
}
|
|
2062
|
+
}, _callee3, this);
|
|
2063
|
+
}));
|
|
2064
|
+
function sendOvertimeTimesheet(_x3) {
|
|
2065
|
+
return _sendOvertimeTimesheet.apply(this, arguments);
|
|
2066
|
+
}
|
|
2067
|
+
return sendOvertimeTimesheet;
|
|
2068
|
+
}();
|
|
2069
|
+
_proto.sendStandbyTimesheet = /*#__PURE__*/function () {
|
|
2070
|
+
var _sendStandbyTimesheet = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
2071
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
2072
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
2073
|
+
case 0:
|
|
2074
|
+
return _context4.abrupt("return", this.sendTimesheet(TimesheetType.Standby, params));
|
|
2075
|
+
case 1:
|
|
2076
|
+
case "end":
|
|
2077
|
+
return _context4.stop();
|
|
2078
|
+
}
|
|
2079
|
+
}, _callee4, this);
|
|
2080
|
+
}));
|
|
2081
|
+
function sendStandbyTimesheet(_x4) {
|
|
2082
|
+
return _sendStandbyTimesheet.apply(this, arguments);
|
|
2083
|
+
}
|
|
2084
|
+
return sendStandbyTimesheet;
|
|
2085
|
+
}();
|
|
2086
|
+
_proto.sendTimesheet = /*#__PURE__*/function () {
|
|
2087
|
+
var _sendTimesheet = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(type, params) {
|
|
2088
|
+
var form, response, _error$response;
|
|
2089
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
2090
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
2091
|
+
case 0:
|
|
2092
|
+
_context5.prev = 0;
|
|
2093
|
+
form = new FormData();
|
|
2094
|
+
form.append('workorder_id', params.workorder_id);
|
|
2095
|
+
form.append('start', this.formatDateTime(params.start));
|
|
2096
|
+
form.append('end', this.formatDateTime(params.end));
|
|
2097
|
+
if (type === TimesheetType.Callback && 'reason' in params) {
|
|
2098
|
+
form.append('reason', params.reason);
|
|
2099
|
+
}
|
|
2100
|
+
if (type === TimesheetType.Standby && 'calls_order' in params) {
|
|
2101
|
+
form.append('calls_order', params.calls_order);
|
|
2102
|
+
}
|
|
2103
|
+
_context5.next = 9;
|
|
2104
|
+
return this.axios.post("v3/workorderLog/" + type, form, {
|
|
2105
|
+
headers: form.getHeaders()
|
|
2106
|
+
});
|
|
2107
|
+
case 9:
|
|
2108
|
+
response = _context5.sent;
|
|
2109
|
+
return _context5.abrupt("return", {
|
|
2110
|
+
success: true,
|
|
2111
|
+
data: response.data
|
|
2112
|
+
});
|
|
2113
|
+
case 13:
|
|
2114
|
+
_context5.prev = 13;
|
|
2115
|
+
_context5.t0 = _context5["catch"](0);
|
|
2116
|
+
return _context5.abrupt("return", {
|
|
2117
|
+
success: false,
|
|
2118
|
+
error: _context5.t0.message || 'Failed to send timesheet',
|
|
2119
|
+
data: (_error$response = _context5.t0.response) == null ? void 0 : _error$response.data
|
|
2120
|
+
});
|
|
2121
|
+
case 16:
|
|
2122
|
+
case "end":
|
|
2123
|
+
return _context5.stop();
|
|
2124
|
+
}
|
|
2125
|
+
}, _callee5, this, [[0, 13]]);
|
|
2126
|
+
}));
|
|
2127
|
+
function sendTimesheet(_x5, _x6) {
|
|
2128
|
+
return _sendTimesheet.apply(this, arguments);
|
|
2129
|
+
}
|
|
2130
|
+
return sendTimesheet;
|
|
2131
|
+
}()
|
|
2132
|
+
/**
|
|
2133
|
+
* Converts a Date object to the required string format: "YYYY-MM-DD HH:mm"
|
|
2134
|
+
*/
|
|
2135
|
+
;
|
|
2136
|
+
_proto.formatDateTime = function formatDateTime(date) {
|
|
2137
|
+
var year = date.getFullYear();
|
|
2138
|
+
var month = String(date.getMonth() + 1).padStart(2, '0');
|
|
2139
|
+
var day = String(date.getDate()).padStart(2, '0');
|
|
2140
|
+
var hours = String(date.getHours()).padStart(2, '0');
|
|
2141
|
+
var minutes = String(date.getMinutes()).padStart(2, '0');
|
|
2142
|
+
return year + "-" + month + "-" + day + " " + hours + ":" + minutes;
|
|
2143
|
+
};
|
|
2144
|
+
return TimesheetClient;
|
|
2145
|
+
}();
|
|
2146
|
+
|
|
1999
2147
|
var LipheApiClient = /*#__PURE__*/function () {
|
|
2000
2148
|
function LipheApiClient(baseUrl, email, password, type) {
|
|
2001
2149
|
if (type === void 0) {
|
|
@@ -2016,6 +2164,7 @@ var LipheApiClient = /*#__PURE__*/function () {
|
|
|
2016
2164
|
});
|
|
2017
2165
|
this.practitionerClient = new LiphePractitionerClient(this.axiosInstance);
|
|
2018
2166
|
this.contractRequestPeriodClient = new ContractRequestPeriodClient(this.axiosInstance);
|
|
2167
|
+
this.timesheetClient = new TimesheetClient(this.axiosInstance);
|
|
2019
2168
|
}
|
|
2020
2169
|
var _proto = LipheApiClient.prototype;
|
|
2021
2170
|
_proto.init = /*#__PURE__*/function () {
|