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.
@@ -1369,7 +1369,7 @@ var SFPriceClient = /*#__PURE__*/function () {
1369
1369
  return SFPriceClient;
1370
1370
  }();
1371
1371
 
1372
- var ACCOUNT_FIELDS = ['Id', 'Name', 'BillingCity', 'BillingState', 'BillingPostalCode', 'BillingCountry', 'BillingAddress', 'Phone', 'Fax', 'Type'];
1372
+ var ACCOUNT_FIELDS = ['Id', 'Name', 'BillingCity', 'BillingState', 'BillingPostalCode', 'BillingCountry', 'BillingAddress', 'Phone', 'Fax', 'Type', 'Client_Number__c'];
1373
1373
  var SFAccounts = /*#__PURE__*/function () {
1374
1374
  function SFAccounts(axiosInstance) {
1375
1375
  this.axiosInstance = axiosInstance;
@@ -1497,7 +1497,8 @@ var SFAccounts = /*#__PURE__*/function () {
1497
1497
  email: null,
1498
1498
  phone2: null,
1499
1499
  cellular: null,
1500
- lang: 'eng'
1500
+ lang: 'eng',
1501
+ clientNumber: record.Client_Number__c
1501
1502
  };
1502
1503
  };
1503
1504
  return SFAccounts;
@@ -1682,8 +1683,8 @@ var LipheAuthenticator = /*#__PURE__*/function () {
1682
1683
  }();
1683
1684
  _proto.login = /*#__PURE__*/function () {
1684
1685
  var _login = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
1685
- var _response$data;
1686
- var form, response, token;
1686
+ var _responseData;
1687
+ var form, response, responseData, jsonMatch, token;
1687
1688
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1688
1689
  while (1) switch (_context3.prev = _context3.next) {
1689
1690
  case 0:
@@ -1697,16 +1698,23 @@ var LipheAuthenticator = /*#__PURE__*/function () {
1697
1698
  });
1698
1699
  case 6:
1699
1700
  response = _context3.sent;
1700
- token = response == null || (_response$data = response.data) == null || (_response$data = _response$data.data) == null ? void 0 : _response$data.token;
1701
+ responseData = response.data;
1702
+ if (typeof responseData === 'string') {
1703
+ jsonMatch = responseData.match(/^\{.*?}(?=HTTP|$)/);
1704
+ if (jsonMatch) {
1705
+ responseData = JSON.parse(jsonMatch[0]);
1706
+ }
1707
+ }
1708
+ token = (_responseData = responseData) == null || (_responseData = _responseData.data) == null ? void 0 : _responseData.token;
1701
1709
  if (token) {
1702
- _context3.next = 10;
1710
+ _context3.next = 12;
1703
1711
  break;
1704
1712
  }
1705
1713
  throw new Error('Authentication failed: no token return');
1706
- case 10:
1714
+ case 12:
1707
1715
  this.token = token;
1708
1716
  return _context3.abrupt("return", token);
1709
- case 12:
1717
+ case 14:
1710
1718
  case "end":
1711
1719
  return _context3.stop();
1712
1720
  }
@@ -1990,6 +1998,146 @@ var ContractRequestPeriodClient = /*#__PURE__*/function () {
1990
1998
  return ContractRequestPeriodClient;
1991
1999
  }();
1992
2000
 
2001
+ var TimesheetType = {
2002
+ Regular: 'regular',
2003
+ Callback: 'callback',
2004
+ Overtime: 'overtime',
2005
+ Standby: 'standby'
2006
+ };
2007
+ var TimesheetClient = /*#__PURE__*/function () {
2008
+ function TimesheetClient(axiosInstance) {
2009
+ this.axios = axiosInstance;
2010
+ }
2011
+ var _proto = TimesheetClient.prototype;
2012
+ _proto.sendRegularTimesheet = /*#__PURE__*/function () {
2013
+ var _sendRegularTimesheet = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
2014
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
2015
+ while (1) switch (_context.prev = _context.next) {
2016
+ case 0:
2017
+ return _context.abrupt("return", this.sendTimesheet(TimesheetType.Regular, params));
2018
+ case 1:
2019
+ case "end":
2020
+ return _context.stop();
2021
+ }
2022
+ }, _callee, this);
2023
+ }));
2024
+ function sendRegularTimesheet(_x) {
2025
+ return _sendRegularTimesheet.apply(this, arguments);
2026
+ }
2027
+ return sendRegularTimesheet;
2028
+ }();
2029
+ _proto.sendCallbackTimesheet = /*#__PURE__*/function () {
2030
+ var _sendCallbackTimesheet = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
2031
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2032
+ while (1) switch (_context2.prev = _context2.next) {
2033
+ case 0:
2034
+ return _context2.abrupt("return", this.sendTimesheet(TimesheetType.Callback, params));
2035
+ case 1:
2036
+ case "end":
2037
+ return _context2.stop();
2038
+ }
2039
+ }, _callee2, this);
2040
+ }));
2041
+ function sendCallbackTimesheet(_x2) {
2042
+ return _sendCallbackTimesheet.apply(this, arguments);
2043
+ }
2044
+ return sendCallbackTimesheet;
2045
+ }();
2046
+ _proto.sendOvertimeTimesheet = /*#__PURE__*/function () {
2047
+ var _sendOvertimeTimesheet = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
2048
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
2049
+ while (1) switch (_context3.prev = _context3.next) {
2050
+ case 0:
2051
+ return _context3.abrupt("return", this.sendTimesheet(TimesheetType.Overtime, params));
2052
+ case 1:
2053
+ case "end":
2054
+ return _context3.stop();
2055
+ }
2056
+ }, _callee3, this);
2057
+ }));
2058
+ function sendOvertimeTimesheet(_x3) {
2059
+ return _sendOvertimeTimesheet.apply(this, arguments);
2060
+ }
2061
+ return sendOvertimeTimesheet;
2062
+ }();
2063
+ _proto.sendStandbyTimesheet = /*#__PURE__*/function () {
2064
+ var _sendStandbyTimesheet = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
2065
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
2066
+ while (1) switch (_context4.prev = _context4.next) {
2067
+ case 0:
2068
+ return _context4.abrupt("return", this.sendTimesheet(TimesheetType.Standby, params));
2069
+ case 1:
2070
+ case "end":
2071
+ return _context4.stop();
2072
+ }
2073
+ }, _callee4, this);
2074
+ }));
2075
+ function sendStandbyTimesheet(_x4) {
2076
+ return _sendStandbyTimesheet.apply(this, arguments);
2077
+ }
2078
+ return sendStandbyTimesheet;
2079
+ }();
2080
+ _proto.sendTimesheet = /*#__PURE__*/function () {
2081
+ var _sendTimesheet = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(type, params) {
2082
+ var form, response, _error$response;
2083
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
2084
+ while (1) switch (_context5.prev = _context5.next) {
2085
+ case 0:
2086
+ _context5.prev = 0;
2087
+ form = new FormData();
2088
+ form.append('workorder_id', params.workorder_id);
2089
+ form.append('start', this.formatDateTime(params.start));
2090
+ form.append('end', this.formatDateTime(params.end));
2091
+ if (type === TimesheetType.Callback && 'reason' in params) {
2092
+ form.append('reason', params.reason);
2093
+ }
2094
+ if (type === TimesheetType.Standby && 'calls_order' in params) {
2095
+ form.append('calls_order', params.calls_order);
2096
+ }
2097
+ _context5.next = 9;
2098
+ return this.axios.post("v3/workorderLog/" + type, form, {
2099
+ headers: form.getHeaders()
2100
+ });
2101
+ case 9:
2102
+ response = _context5.sent;
2103
+ return _context5.abrupt("return", {
2104
+ success: true,
2105
+ data: response.data
2106
+ });
2107
+ case 13:
2108
+ _context5.prev = 13;
2109
+ _context5.t0 = _context5["catch"](0);
2110
+ return _context5.abrupt("return", {
2111
+ success: false,
2112
+ error: _context5.t0.message || 'Failed to send timesheet',
2113
+ data: (_error$response = _context5.t0.response) == null ? void 0 : _error$response.data
2114
+ });
2115
+ case 16:
2116
+ case "end":
2117
+ return _context5.stop();
2118
+ }
2119
+ }, _callee5, this, [[0, 13]]);
2120
+ }));
2121
+ function sendTimesheet(_x5, _x6) {
2122
+ return _sendTimesheet.apply(this, arguments);
2123
+ }
2124
+ return sendTimesheet;
2125
+ }()
2126
+ /**
2127
+ * Converts a Date object to the required string format: "YYYY-MM-DD HH:mm"
2128
+ */
2129
+ ;
2130
+ _proto.formatDateTime = function formatDateTime(date) {
2131
+ var year = date.getFullYear();
2132
+ var month = String(date.getMonth() + 1).padStart(2, '0');
2133
+ var day = String(date.getDate()).padStart(2, '0');
2134
+ var hours = String(date.getHours()).padStart(2, '0');
2135
+ var minutes = String(date.getMinutes()).padStart(2, '0');
2136
+ return year + "-" + month + "-" + day + " " + hours + ":" + minutes;
2137
+ };
2138
+ return TimesheetClient;
2139
+ }();
2140
+
1993
2141
  var LipheApiClient = /*#__PURE__*/function () {
1994
2142
  function LipheApiClient(baseUrl, email, password, type) {
1995
2143
  if (type === void 0) {
@@ -2010,6 +2158,7 @@ var LipheApiClient = /*#__PURE__*/function () {
2010
2158
  });
2011
2159
  this.practitionerClient = new LiphePractitionerClient(this.axiosInstance);
2012
2160
  this.contractRequestPeriodClient = new ContractRequestPeriodClient(this.axiosInstance);
2161
+ this.timesheetClient = new TimesheetClient(this.axiosInstance);
2013
2162
  }
2014
2163
  var _proto = LipheApiClient.prototype;
2015
2164
  _proto.init = /*#__PURE__*/function () {