@cemiar/cemiarlink-sdk 1.0.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.
Files changed (108) hide show
  1. package/README.md +2 -0
  2. package/dist/exceptions/EpicException.d.ts +3 -0
  3. package/dist/exceptions/EpicException.js +10 -0
  4. package/dist/exceptions/MissingInfo.d.ts +3 -0
  5. package/dist/exceptions/MissingInfo.js +10 -0
  6. package/dist/exceptions/NotProcessYet.d.ts +3 -0
  7. package/dist/exceptions/NotProcessYet.js +10 -0
  8. package/dist/index.d.ts +7 -0
  9. package/dist/index.js +54 -0
  10. package/dist/models/admin/BusMessage.d.ts +4 -0
  11. package/dist/models/admin/BusMessage.js +2 -0
  12. package/dist/models/admin/Counter.d.ts +8 -0
  13. package/dist/models/admin/Counter.js +2 -0
  14. package/dist/models/admin/Email.d.ts +49 -0
  15. package/dist/models/admin/Email.js +2 -0
  16. package/dist/models/admin/ExcelSheet.d.ts +5 -0
  17. package/dist/models/admin/ExcelSheet.js +2 -0
  18. package/dist/models/admin/ExtractTable.d.ts +37 -0
  19. package/dist/models/admin/ExtractTable.js +2 -0
  20. package/dist/models/admin/IDictionary.d.ts +3 -0
  21. package/dist/models/admin/IDictionary.js +2 -0
  22. package/dist/models/admin/KimobyResult.d.ts +17 -0
  23. package/dist/models/admin/KimobyResult.js +2 -0
  24. package/dist/models/admin/PdfReader.d.ts +26 -0
  25. package/dist/models/admin/PdfReader.js +2 -0
  26. package/dist/models/admin/Primaco.d.ts +14 -0
  27. package/dist/models/admin/Primaco.js +2 -0
  28. package/dist/models/admin/index.d.ts +9 -0
  29. package/dist/models/admin/index.js +25 -0
  30. package/dist/models/epic/Activity.d.ts +83 -0
  31. package/dist/models/epic/Activity.js +2 -0
  32. package/dist/models/epic/AdditionalInterest.d.ts +15 -0
  33. package/dist/models/epic/AdditionalInterest.js +2 -0
  34. package/dist/models/epic/Address.d.ts +10 -0
  35. package/dist/models/epic/Address.js +2 -0
  36. package/dist/models/epic/Attachment.d.ts +47 -0
  37. package/dist/models/epic/Attachment.js +2 -0
  38. package/dist/models/epic/Broker.d.ts +38 -0
  39. package/dist/models/epic/Broker.js +2 -0
  40. package/dist/models/epic/Claim.d.ts +24 -0
  41. package/dist/models/epic/Claim.js +2 -0
  42. package/dist/models/epic/Commission.d.ts +76 -0
  43. package/dist/models/epic/Commission.js +2 -0
  44. package/dist/models/epic/Company.d.ts +9 -0
  45. package/dist/models/epic/Company.js +2 -0
  46. package/dist/models/epic/Contact.d.ts +49 -0
  47. package/dist/models/epic/Contact.js +2 -0
  48. package/dist/models/epic/Customer.d.ts +98 -0
  49. package/dist/models/epic/Customer.js +2 -0
  50. package/dist/models/epic/DirectBillCommission.d.ts +18 -0
  51. package/dist/models/epic/DirectBillCommission.js +2 -0
  52. package/dist/models/epic/Driver.d.ts +67 -0
  53. package/dist/models/epic/Driver.js +2 -0
  54. package/dist/models/epic/Employee.d.ts +145 -0
  55. package/dist/models/epic/Employee.js +2 -0
  56. package/dist/models/epic/GeneralLedgerReconcileBank.d.ts +117 -0
  57. package/dist/models/epic/GeneralLedgerReconcileBank.js +2 -0
  58. package/dist/models/epic/Habitational.d.ts +156 -0
  59. package/dist/models/epic/Habitational.js +2 -0
  60. package/dist/models/epic/Line.d.ts +169 -0
  61. package/dist/models/epic/Line.js +2 -0
  62. package/dist/models/epic/Lookup.d.ts +5 -0
  63. package/dist/models/epic/Lookup.js +2 -0
  64. package/dist/models/epic/MultiCarrierSchedule.d.ts +70 -0
  65. package/dist/models/epic/MultiCarrierSchedule.js +11 -0
  66. package/dist/models/epic/Opportunity.d.ts +45 -0
  67. package/dist/models/epic/Opportunity.js +2 -0
  68. package/dist/models/epic/OptionType.d.ts +4 -0
  69. package/dist/models/epic/OptionType.js +2 -0
  70. package/dist/models/epic/PayableContract.d.ts +19 -0
  71. package/dist/models/epic/PayableContract.js +2 -0
  72. package/dist/models/epic/Policy.d.ts +129 -0
  73. package/dist/models/epic/Policy.js +2 -0
  74. package/dist/models/epic/PolicyV2.d.ts +157 -0
  75. package/dist/models/epic/PolicyV2.js +2 -0
  76. package/dist/models/epic/Receipt.d.ts +142 -0
  77. package/dist/models/epic/Receipt.js +2 -0
  78. package/dist/models/epic/RenewalStage.d.ts +5 -0
  79. package/dist/models/epic/RenewalStage.js +2 -0
  80. package/dist/models/epic/Response.d.ts +9 -0
  81. package/dist/models/epic/Response.js +2 -0
  82. package/dist/models/epic/ServiceSummary.d.ts +16 -0
  83. package/dist/models/epic/ServiceSummary.js +8 -0
  84. package/dist/models/epic/ServicingContact.d.ts +6 -0
  85. package/dist/models/epic/ServicingContact.js +2 -0
  86. package/dist/models/epic/Transaction.d.ts +261 -0
  87. package/dist/models/epic/Transaction.js +2 -0
  88. package/dist/models/epic/Vehicle.d.ts +87 -0
  89. package/dist/models/epic/Vehicle.js +2 -0
  90. package/dist/models/epic/index.d.ts +17 -0
  91. package/dist/models/epic/index.js +33 -0
  92. package/dist/services/Admin.d.ts +30 -0
  93. package/dist/services/Admin.js +200 -0
  94. package/dist/services/BaseEpicService.d.ts +12 -0
  95. package/dist/services/BaseEpicService.js +102 -0
  96. package/dist/services/Epic.d.ts +105 -0
  97. package/dist/services/Epic.js +291 -0
  98. package/dist/services/JobEpicService.d.ts +7 -0
  99. package/dist/services/JobEpicService.js +16 -0
  100. package/dist/services/MultiCarrierScheduleEpicService.d.ts +8 -0
  101. package/dist/services/MultiCarrierScheduleEpicService.js +19 -0
  102. package/dist/utils/AxiosClient.d.ts +6 -0
  103. package/dist/utils/AxiosClient.js +35 -0
  104. package/dist/utils/DeepPartial.d.ts +3 -0
  105. package/dist/utils/DeepPartial.js +2 -0
  106. package/dist/utils/Excel.d.ts +8 -0
  107. package/dist/utils/Excel.js +99 -0
  108. package/package.json +33 -0
@@ -0,0 +1,87 @@
1
+ export interface Vehicle {
2
+ VehicleID: number;
3
+ LineID: number;
4
+ Description: VehicleModel.Description;
5
+ Additionnals: VehicleModel.Additionnal[];
6
+ AdditionnalCoverages: VehicleModel.AdditionnalCoverage[];
7
+ Discounts: VehicleModel.Discount[];
8
+ VehicleRating: VehicleModel.VehicleRating;
9
+ OptionalAdditionalCoverageItems: VehicleModel.AdditionnalCoverage[];
10
+ Limits: any;
11
+ }
12
+ export declare namespace VehicleModel {
13
+ interface Description {
14
+ TradeName: string;
15
+ Model: string;
16
+ ModelYear: number | null;
17
+ VehicleIdentificationNumber: string;
18
+ BodyTypeCode?: string;
19
+ BodyTypeIfOther?: string;
20
+ }
21
+ interface AdditionnalCoverage {
22
+ AdditionalCoverageID: number;
23
+ CoverageCode: string;
24
+ CoverageEffectiveDate: string;
25
+ CoverageExpiryDate: string;
26
+ CoverageExpirationDate?: string;
27
+ Deductible: string;
28
+ Description: string;
29
+ FormEditionDate: null;
30
+ FormNumber: string;
31
+ IsReadOnly: true;
32
+ Limit1: string;
33
+ Limit2: string;
34
+ LineID: number;
35
+ NetChangePremium: number;
36
+ NumValue: string;
37
+ NumericValue?: string;
38
+ Occurrence: string;
39
+ OptionCode: string;
40
+ PercentCoinsurance: null;
41
+ Premium: number;
42
+ Rate?: string;
43
+ Timestamp: string;
44
+ VehicleID: number;
45
+ YesNoIndicator: string;
46
+ Flag?: string;
47
+ OptionalAdditionalCoverageID?: string;
48
+ }
49
+ interface Additionnal {
50
+ Code: string;
51
+ Deductible: string;
52
+ Description: string;
53
+ Form: string;
54
+ Id: string;
55
+ NumericValue: string;
56
+ OptionCode: string;
57
+ Premium: number | null;
58
+ Limit1: string;
59
+ Limit2: string;
60
+ }
61
+ interface Discount {
62
+ Code: string;
63
+ Description: string;
64
+ Id: number;
65
+ Premium: number | null;
66
+ Percentage: number | null;
67
+ }
68
+ interface VehicleRating {
69
+ FacilityRefusalCode: string;
70
+ FacilityTierCode: string;
71
+ FacilityTierDate: string | null;
72
+ OccasionalDriverRatingClass: string;
73
+ OccasionalDriverRatingDrivingRecordColl: string;
74
+ OccasionalDriverRatingDrivingRecordTPL: string;
75
+ RatingClass: string;
76
+ RatingDrivingRecordColl: string;
77
+ RatingDrivingRecordTPL: string;
78
+ RatingLocation: string;
79
+ RatingRateGroupAB: string;
80
+ RatingRateGroupCollAP: string;
81
+ RatingRateGroupCompSP: string;
82
+ RatingRateGroupDCPD: string;
83
+ RatingSubClass: string | null;
84
+ RatingTerritory: string;
85
+ RatingVehicleCode: string;
86
+ }
87
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,17 @@
1
+ export * from './Activity.js';
2
+ export * from './Address.js';
3
+ export * from './Attachment.js';
4
+ export * from './Broker.js';
5
+ export * from './Commission.js';
6
+ export * from './Company.js';
7
+ export * from './Contact.js';
8
+ export * from './Customer.js';
9
+ export * from './Habitational.js';
10
+ export * from './Lookup.js';
11
+ export * from './Opportunity.js';
12
+ export * from './Policy.js';
13
+ export * from './Response.js';
14
+ export * from './ServiceSummary.js';
15
+ export * from './ServicingContact.js';
16
+ export * from './Transaction.js';
17
+ export * from './Employee.js';
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Activity.js"), exports);
18
+ __exportStar(require("./Address.js"), exports);
19
+ __exportStar(require("./Attachment.js"), exports);
20
+ __exportStar(require("./Broker.js"), exports);
21
+ __exportStar(require("./Commission.js"), exports);
22
+ __exportStar(require("./Company.js"), exports);
23
+ __exportStar(require("./Contact.js"), exports);
24
+ __exportStar(require("./Customer.js"), exports);
25
+ __exportStar(require("./Habitational.js"), exports);
26
+ __exportStar(require("./Lookup.js"), exports);
27
+ __exportStar(require("./Opportunity.js"), exports);
28
+ __exportStar(require("./Policy.js"), exports);
29
+ __exportStar(require("./Response.js"), exports);
30
+ __exportStar(require("./ServiceSummary.js"), exports);
31
+ __exportStar(require("./ServicingContact.js"), exports);
32
+ __exportStar(require("./Transaction.js"), exports);
33
+ __exportStar(require("./Employee.js"), exports);
@@ -0,0 +1,30 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { AzureOCRResponse, ClassificationResult, Counter, Email, EmailAws, BusMessagePayload, ExtractBody, ExtractInsurerResponse, ExtractTableResponse, FlashPaymentRequest, PdfReaderBody, PdfReaderResponse, SendMailResult, TableExtractBody } from "../models/admin/index.js";
3
+ export default class AdminService {
4
+ axiosInstance: AxiosInstance;
5
+ taskId?: string;
6
+ constructor(adminUrl: string | undefined, headers: object, taskId?: string);
7
+ updateCemiarTask(status: string): Promise<void>;
8
+ pdfReader(route: string, issuingCompany: string, payload: object): Promise<PdfReaderResponse>;
9
+ pdfCompare(payload: PdfReaderBody, apiVersion: string): Promise<Buffer>;
10
+ pdfCompareExcel(payload: PdfReaderBody, apiVersion: string): Promise<Buffer>;
11
+ extractTableFromBase64(payload: TableExtractBody): Promise<ExtractTableResponse[]>;
12
+ extractInsurerFromBase64(payload: ExtractBody): Promise<ExtractInsurerResponse>;
13
+ extractVehicles(payload: object): Promise<any>;
14
+ azureOCRExtraction(payload: object): Promise<AzureOCRResponse[]>;
15
+ sendTextMessage(message: string, phoneNumber: string, name: string, enterprise: string | undefined): Promise<void>;
16
+ getModuleConfig(): Promise<any>;
17
+ getReportData<T>(date: string, fileName: string, sheetNumber: number): Promise<T[]>;
18
+ getTestData<T>(fileName: string, sheetNumber: number): Promise<T[]>;
19
+ saveTestResult<T>(result: T[], fileName: string): Promise<void>;
20
+ removeReportFiles(date: string, fileName: string): Promise<void>;
21
+ unSyncFiles(): Promise<void>;
22
+ createReport(sheatData: string[][], headers: string[], name: string): Promise<void>;
23
+ getPrimacoFlashPaymentLink(request: FlashPaymentRequest, enterprise: string | undefined): Promise<any>;
24
+ getCounter(taskId: string): Promise<Counter>;
25
+ updateCounter(counterId: string, numberOfRequest: number): Promise<any>;
26
+ classifyDocument(insurer: string, fileContentBase64: string): Promise<ClassificationResult[]>;
27
+ sendMessagesToQueue(queue: string, messages: BusMessagePayload): Promise<void>;
28
+ sendNotification(notification: Email): Promise<void>;
29
+ sendEmailAws(emailBody: EmailAws): Promise<SendMailResult>;
30
+ }
@@ -0,0 +1,200 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fs_1 = __importDefault(require("fs"));
7
+ const path_1 = __importDefault(require("path"));
8
+ const AxiosClient_js_1 = require("../utils/AxiosClient.js");
9
+ const MissingInfo_js_1 = require("../exceptions/MissingInfo.js");
10
+ const Excel_js_1 = __importDefault(require("../utils/Excel.js"));
11
+ class AdminService {
12
+ constructor(adminUrl, headers, taskId) {
13
+ this.taskId = taskId;
14
+ this.axiosInstance = new AxiosClient_js_1.AxiosClient(adminUrl, headers).getInstance();
15
+ }
16
+ async updateCemiarTask(status) {
17
+ const dateTime = new Date();
18
+ const nextDate = new Date().setDate(new Date().getDate() + 1);
19
+ // update the task with the last run date and the next run date with status 200
20
+ await this.axiosInstance.put('task/' + this.taskId, {
21
+ lastRunDate: dateTime,
22
+ nextRunDueDate: nextDate,
23
+ lastStatus: status,
24
+ });
25
+ }
26
+ async pdfReader(route, issuingCompany, payload) {
27
+ const { data: pdfReaderResponse } = await this.axiosInstance.post('pdfReader/' + route + '/' + issuingCompany, payload);
28
+ return pdfReaderResponse;
29
+ }
30
+ async pdfCompare(payload, apiVersion) {
31
+ const response = await this.axiosInstance.post(`pdfReader/compare/${apiVersion}`, payload, {
32
+ responseType: 'arraybuffer',
33
+ });
34
+ return response.data;
35
+ }
36
+ async pdfCompareExcel(payload, apiVersion) {
37
+ const response = await this.axiosInstance.post(`pdfReader/compare/${apiVersion}/excel`, payload, {
38
+ responseType: 'arraybuffer',
39
+ });
40
+ return response.data;
41
+ }
42
+ async extractTableFromBase64(payload) {
43
+ const { data: extraction } = await this.axiosInstance.post('pdfReader/extractTable', payload);
44
+ return extraction;
45
+ }
46
+ async extractInsurerFromBase64(payload) {
47
+ const { data: extraction } = await this.axiosInstance.post('pdfReader/insurerExtractor', payload);
48
+ return extraction;
49
+ }
50
+ async extractVehicles(payload) {
51
+ const result = await this.axiosInstance.post(`pdfReader/extractVehicles`, payload);
52
+ return result.data;
53
+ }
54
+ async azureOCRExtraction(payload) {
55
+ const { data: extraction } = await this.axiosInstance.post('pdfReader/azureOCR', payload);
56
+ return extraction.data;
57
+ }
58
+ async sendTextMessage(message, phoneNumber, name, enterprise) {
59
+ var _a;
60
+ try {
61
+ await this.axiosInstance.post('kimoby/send/' + enterprise, {
62
+ to: phoneNumber,
63
+ message: message,
64
+ name: name,
65
+ });
66
+ }
67
+ catch (error) {
68
+ if (((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) === 400) {
69
+ throw new MissingInfo_js_1.MissingInfo(error.response.data.message);
70
+ }
71
+ throw error;
72
+ }
73
+ }
74
+ async getModuleConfig() {
75
+ const { data: result } = await this.axiosInstance.get('task/' + this.taskId);
76
+ return result[0].config;
77
+ }
78
+ async getReportData(date, fileName, sheetNumber) {
79
+ let data = [];
80
+ let filePath = `./temp/Rapport ${fileName} du ${date}`;
81
+ if (fs_1.default.existsSync(`${filePath}.csv`)) {
82
+ data = await Excel_js_1.default.getFromCSV(`${filePath}.csv`);
83
+ }
84
+ else if (fs_1.default.existsSync(`${filePath}.xlsx`)) {
85
+ data = await Excel_js_1.default.getFromXLSX(`${filePath}.xlsx`, sheetNumber);
86
+ }
87
+ else {
88
+ return [];
89
+ }
90
+ return data;
91
+ }
92
+ async getTestData(fileName, sheetNumber) {
93
+ let data = [];
94
+ let filePath = `./test/${fileName}`;
95
+ if (fs_1.default.existsSync(`${filePath}.csv`)) {
96
+ data = await Excel_js_1.default.getFromCSV(`${filePath}.csv`);
97
+ }
98
+ else if (fs_1.default.existsSync(`${filePath}.xlsx`)) {
99
+ data = await Excel_js_1.default.getFromXLSX(`${filePath}.xlsx`, sheetNumber);
100
+ }
101
+ else {
102
+ return [];
103
+ }
104
+ return data;
105
+ }
106
+ async saveTestResult(result, fileName) {
107
+ let filePath = `./test/${fileName}Result.ts`;
108
+ fs_1.default.writeFileSync(filePath, JSON.stringify(result));
109
+ }
110
+ async removeReportFiles(date, fileName) {
111
+ if (fs_1.default.existsSync(`./temp/Rapport ${fileName} du ${date}.xlsx`)) {
112
+ fs_1.default.unlinkSync(`./temp/Rapport ${fileName} du ${date}.xlsx`);
113
+ }
114
+ }
115
+ async unSyncFiles() {
116
+ const invoiceFormats = ['docx', 'pdf', 'xlsx', 'eml', 'csv', 'html'];
117
+ const directory = './result/';
118
+ if (!fs_1.default.existsSync(directory)) {
119
+ return;
120
+ }
121
+ fs_1.default.readdirSync(directory).forEach((file) => {
122
+ for (const format of invoiceFormats) {
123
+ const fileType = file.split('.')[file.split('.').length - 1];
124
+ if (fileType.includes(format)) {
125
+ const filePath = path_1.default.join(directory, file);
126
+ fs_1.default.unlinkSync(filePath);
127
+ }
128
+ }
129
+ });
130
+ }
131
+ async createReport(sheatData, headers, name) {
132
+ if (name.includes('.xlsx')) {
133
+ Excel_js_1.default.createFile(sheatData, headers, name);
134
+ }
135
+ if (name.includes('.csv')) {
136
+ Excel_js_1.default.appendFile(headers, name);
137
+ for (const row of sheatData) {
138
+ Excel_js_1.default.appendFile(row, name);
139
+ }
140
+ }
141
+ }
142
+ //DO NOT USE
143
+ async getPrimacoFlashPaymentLink(request, enterprise) {
144
+ var _a;
145
+ try {
146
+ return await this.axiosInstance.post(`primaco/${enterprise}/flash`, request);
147
+ }
148
+ catch (error) {
149
+ if (((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) === 400) {
150
+ throw new MissingInfo_js_1.MissingInfo(error.response.data.message);
151
+ }
152
+ throw error;
153
+ }
154
+ }
155
+ async getCounter(taskId) {
156
+ var _a;
157
+ try {
158
+ const { data: result } = await this.axiosInstance.get(`counter?taskID=${taskId}`);
159
+ return result[0];
160
+ }
161
+ catch (error) {
162
+ if (((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) === 400) {
163
+ throw new MissingInfo_js_1.MissingInfo(error.response.data.message);
164
+ }
165
+ throw error;
166
+ }
167
+ }
168
+ async updateCounter(counterId, numberOfRequest) {
169
+ var _a;
170
+ try {
171
+ return await this.axiosInstance.put(`counter/${counterId}`, {
172
+ numberOfRequest: numberOfRequest,
173
+ });
174
+ }
175
+ catch (error) {
176
+ if (((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) === 400) {
177
+ throw new MissingInfo_js_1.MissingInfo(error.response.data.message);
178
+ }
179
+ throw error;
180
+ }
181
+ }
182
+ async classifyDocument(insurer, fileContentBase64) {
183
+ const result = await this.axiosInstance.post(`/pdfReader/classifyDocument/${insurer}`, {
184
+ base64: fileContentBase64,
185
+ metadata: {},
186
+ });
187
+ return result.data;
188
+ }
189
+ async sendMessagesToQueue(queue, messages) {
190
+ await this.axiosInstance.post('/busMessages/' + queue, messages);
191
+ }
192
+ async sendNotification(notification) {
193
+ await this.axiosInstance.post('/sendEmail', notification);
194
+ }
195
+ async sendEmailAws(emailBody) {
196
+ const result = await this.axiosInstance.post('/mail/send', emailBody);
197
+ return result.data;
198
+ }
199
+ }
200
+ exports.default = AdminService;
@@ -0,0 +1,12 @@
1
+ import { AxiosInstance } from 'axios';
2
+ export default class BaseEpicService {
3
+ axiosInstance: AxiosInstance;
4
+ constructor(epicUrl: string | undefined, headers: any);
5
+ private handleError;
6
+ get(endpoint: string, queryParams?: object): Promise<any>;
7
+ getOne(endpoint: string, id: string | number, queryParams?: object): Promise<any>;
8
+ put(endpoint: string, data: object, queryParams?: object): Promise<string>;
9
+ post(endpoint: string, data: object): Promise<string | string[]>;
10
+ delete(endpoint: string, id: string): Promise<string>;
11
+ buildQueryString(queryParams: object): string;
12
+ }
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const AxiosClient_js_1 = require("../utils/AxiosClient.js");
4
+ class BaseEpicService {
5
+ constructor(epicUrl, headers) {
6
+ this.axiosInstance = new AxiosClient_js_1.AxiosClient(epicUrl, headers).getInstance();
7
+ }
8
+ handleError(axiosResponse) {
9
+ if (axiosResponse.bodyError) {
10
+ throw new Error(JSON.stringify(axiosResponse.bodyError, null, 2));
11
+ }
12
+ throw new Error(axiosResponse.message || axiosResponse.Message);
13
+ }
14
+ async get(endpoint, queryParams = {}) {
15
+ const queryString = this.buildQueryString(queryParams);
16
+ const url = `${endpoint}?${queryString}`;
17
+ try {
18
+ const { data: axiosResponse } = await this.axiosInstance.get(url);
19
+ return axiosResponse.result;
20
+ }
21
+ catch (error) {
22
+ if (error.response && error.response.data) {
23
+ throw this.handleError(error.response.data);
24
+ }
25
+ throw new Error(error.message);
26
+ }
27
+ }
28
+ async getOne(endpoint, id, queryParams = {}) {
29
+ let url;
30
+ if (queryParams !== null) {
31
+ const queryString = this.buildQueryString(queryParams);
32
+ url = `${endpoint}/${id}?${queryString}`;
33
+ }
34
+ else {
35
+ url = `${endpoint}/${id}`;
36
+ }
37
+ try {
38
+ const { data: axiosResponse } = await this.axiosInstance.get(url);
39
+ return axiosResponse.result;
40
+ }
41
+ catch (error) {
42
+ if (error.response && error.response.data) {
43
+ throw this.handleError(error.response.data);
44
+ }
45
+ throw new Error(error.message);
46
+ }
47
+ }
48
+ async put(endpoint, data, queryParams = {}) {
49
+ const queryString = this.buildQueryString(queryParams);
50
+ const url = `${endpoint}?${queryString}`;
51
+ try {
52
+ const { data: axiosResponse } = await this.axiosInstance.put(url, data);
53
+ axiosResponse.result = axiosResponse.result.replace(/ /g, '');
54
+ if (axiosResponse.result.split(':')) {
55
+ return axiosResponse.result.split(':')[1];
56
+ }
57
+ return axiosResponse.result.split(':')[1];
58
+ }
59
+ catch (error) {
60
+ if (error.response && error.response.data) {
61
+ throw this.handleError(error.response.data);
62
+ }
63
+ throw new Error(error.message);
64
+ }
65
+ }
66
+ async post(endpoint, data) {
67
+ try {
68
+ const { data: axiosResponse } = await this.axiosInstance.post(endpoint, data);
69
+ axiosResponse.result = axiosResponse.result.replace(/ /g, '');
70
+ const responseArray = axiosResponse.result.split(':')[1].split(',');
71
+ if (responseArray.length === 1) {
72
+ return responseArray[0];
73
+ }
74
+ return responseArray;
75
+ }
76
+ catch (error) {
77
+ if (error.response && error.response.data) {
78
+ throw this.handleError(error.response.data);
79
+ }
80
+ throw new Error(error.message);
81
+ }
82
+ }
83
+ async delete(endpoint, id) {
84
+ const url = `${endpoint}/${id}`;
85
+ try {
86
+ const { data: axiosResponse } = await this.axiosInstance.delete(url);
87
+ return axiosResponse.result;
88
+ }
89
+ catch (error) {
90
+ if (error.response && error.response.data) {
91
+ throw this.handleError(error.response.data);
92
+ }
93
+ throw new Error(error.message);
94
+ }
95
+ }
96
+ buildQueryString(queryParams) {
97
+ return Object.entries(queryParams)
98
+ .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
99
+ .join('&');
100
+ }
101
+ }
102
+ exports.default = BaseEpicService;
@@ -0,0 +1,105 @@
1
+ import { BaseEpicService, JobEpicService, MultiCarrierScheduleEpicService } from "../index.js";
2
+ import { AdditionalInterest } from "../models/epic/AdditionalInterest.js";
3
+ import { Claim } from "../models/epic/Claim.js";
4
+ import { DirectBillCommission } from "../models/epic/DirectBillCommission.js";
5
+ import { Driver } from "../models/epic/Driver.js";
6
+ import { GeneralLedgerReconcileBank } from "../models/epic/GeneralLedgerReconcileBank.js";
7
+ import { Activity, Attachment, AttachmentDetail, Broker, Commission, Company, Contact, CreateActivity, CreateAttachment, CreateContact, CreateCustomer, CreatePaymentTransaction, CreatePolicy, CreateTransaction, Customer, Employee, FinanceTransaction, FinanceTransactionResult, Habitational, LookUp, Opportunity, Policy, Transaction, TransactionApplyCreditsToDebits } from "../models/epic/index.js";
8
+ import { Line } from "../models/epic/Line.js";
9
+ import { PayableContract } from "../models/epic/PayableContract.js";
10
+ import { PolicyV2, PolicyV2Model } from "../models/epic/PolicyV2.js";
11
+ import { Receipt } from "../models/epic/Receipt.js";
12
+ import { RenewalStage } from "../models/epic/RenewalStage.js";
13
+ import { Vehicle } from "../models/epic/Vehicle.js";
14
+ export default class EpicService extends BaseEpicService {
15
+ job: JobEpicService;
16
+ multiCarrierSchedule: MultiCarrierScheduleEpicService;
17
+ constructor(epicUrl: string | undefined, headers: any);
18
+ getActivity(activityId: string): Promise<Activity>;
19
+ getActivities(queryParams: object): Promise<Activity[]>;
20
+ updateActivity(activityId: string, payload: object): Promise<string>;
21
+ createActivity(payload: CreateActivity): Promise<string | string[]>;
22
+ copyActivity(id: string, payload: object): Promise<string>;
23
+ getAttachments(queryParams: object): Promise<Attachment[]>;
24
+ getAttachment(attachmentId: string): Promise<Attachment>;
25
+ updateAttachment(attachmentId: string, payload: object): Promise<string>;
26
+ createAttachment(payload: CreateAttachment): Promise<string | string[]>;
27
+ getAttachmentContent(attachmentId: string): Promise<AttachmentDetail>;
28
+ deleteAttachment(attachmentId: string): Promise<string>;
29
+ getPolicies(queryParams: object): Promise<Policy[]>;
30
+ getPolicy(id: string): Promise<Policy>;
31
+ renewPolicy(id: string, payload: object): Promise<string>;
32
+ updatePolicy(id: string, payload: object): Promise<string>;
33
+ issuePolicy(id: string, payload: object): Promise<string>;
34
+ cancelPolicy(id: string, payload: object): Promise<string>;
35
+ createPolicy(payload: CreatePolicy): Promise<string | string[]>;
36
+ getPoliciesV2(queryParams: object): Promise<PolicyV2[]>;
37
+ getPolicyV2(id: string): Promise<PolicyV2>;
38
+ createPolicyV2(payload: object): Promise<string>;
39
+ updatePolicyV2(id: string, payload: object): Promise<string>;
40
+ renewPolicyV2(payload: PolicyV2Model.RenewPolicy): Promise<string>;
41
+ endorseExistingLinePolicyV2(payload: PolicyV2Model.EndorseExistingLine): Promise<void>;
42
+ cancelPolicyV2(payload: PolicyV2Model.CancelPolicy): Promise<string>;
43
+ issuePolicyV2(payload: PolicyV2Model.IssuePolicy): Promise<void>;
44
+ issueEndorsementPolicyV2(payload: PolicyV2Model.IssueEndorsement): Promise<void>;
45
+ issueCancellationPolicyV2(payload: PolicyV2Model.IssueCancellation): Promise<void>;
46
+ getPolicyV2RenewalStages(ids: number[]): Promise<RenewalStage[]>;
47
+ getEmployee(id: string): Promise<Broker>;
48
+ getEmployees(queryParams: object): Promise<Broker[]>;
49
+ getEmployeeV2(id: number): Promise<Employee>;
50
+ getEmployeesV2(queryParams: object): Promise<Employee[]>;
51
+ createEmployee(payload: object): Promise<string>;
52
+ updateEmployee(id: number, payload: object): Promise<string>;
53
+ getLookUp(queryParams: object): Promise<LookUp[]>;
54
+ getContact(id: string, queryParams: object): Promise<Contact>;
55
+ getContacts(queryParams: object): Promise<Contact[]>;
56
+ createContact(payload: CreateContact): Promise<string | string[]>;
57
+ updateContact(id: string, accountType: string, payload: object): Promise<string>;
58
+ getTransactions(queryParams: object): Promise<Transaction[]>;
59
+ getTransaction(transactionId: string): Promise<Transaction>;
60
+ financeTransaction(transactionId: string, payload: FinanceTransaction): Promise<string | FinanceTransactionResult>;
61
+ reverseTransaction(transactionId: string, payload: object): Promise<string>;
62
+ transactionApplyCreditsToDebits(transactionId: string, payload: TransactionApplyCreditsToDebits): Promise<Receipt[]>;
63
+ updateTransaction(transactionId: string, payload: object): Promise<string>;
64
+ createTransaction(payload: CreateTransaction): Promise<string | string[]>;
65
+ createPaymentTransaction(payload: CreatePaymentTransaction): Promise<string | string[]>;
66
+ getCompany(companyId: string): Promise<Company>;
67
+ getCompanies(queryParams: object): Promise<Company[]>;
68
+ getCustomers(queryParams: object): Promise<Customer[]>;
69
+ getCustomer(clientId: string): Promise<Customer>;
70
+ updateCustomer(clientId: string, payload: object): Promise<string>;
71
+ createCustomer(payload: CreateCustomer): Promise<string | string[]>;
72
+ getHabitationals(queryParams: object): Promise<Habitational[]>;
73
+ getCommissions(commissionId: string, queryParams: object): Promise<Commission>;
74
+ getCommission(commissionId: string): Promise<Commission>;
75
+ getOpportunity(opportunityId: string): Promise<Opportunity>;
76
+ getOpportunities(queryParams: object): Promise<Opportunity[]>;
77
+ updateOpportunity(opportunityId: string, payload: object): Promise<string>;
78
+ createOpportunity(payload: object): Promise<string | string[]>;
79
+ getClaim(claimId: string): Promise<Claim>;
80
+ getClaims(queryParams: object): Promise<Claim[]>;
81
+ getPersonalAutoVehicles(queryParams: object): Promise<Vehicle[]>;
82
+ getPersonalAutoDrivers(queryParams: object): Promise<Driver[]>;
83
+ getCommercialAutoVehicles(queryParams: object): Promise<Vehicle[]>;
84
+ getCommercialAutoDrivers(queryParams: object): Promise<Driver[]>;
85
+ getPolicyLine(lineId: string): Promise<Line>;
86
+ getPolicyLines(queryParams: object): Promise<Line[]>;
87
+ createPolicyLine(policyLine: object): Promise<string>;
88
+ updatePolicyLine(lineId: string, payload: object): Promise<string>;
89
+ getDirectBillCommission(commissionId: string): Promise<DirectBillCommission>;
90
+ getDirectBillCommissions(queryParams: object): Promise<DirectBillCommission[]>;
91
+ updateDirectBillCommission(commissionId: string, payload: object): Promise<string>;
92
+ getReceipts(queryParams: object): Promise<Receipt[]>;
93
+ getReceipt(receiptId: string): Promise<Receipt>;
94
+ updateReceipt(receiptId: string, payload: object): Promise<string>;
95
+ createReceipt(payload: object): Promise<string | string[]>;
96
+ receiptApplyCreditsToDebits(receiptId: string, payload: object): Promise<Receipt[]>;
97
+ getPayableContracts(queryParams: object): Promise<PayableContract[]>;
98
+ getPayableContract(payableContractId: string, queryParams: object): Promise<PayableContract[]>;
99
+ getGeneralLedgerReconcileBanks(queryParams: object): Promise<GeneralLedgerReconcileBank[]>;
100
+ getGeneralLedgerReconcileBank(bankId: string): Promise<GeneralLedgerReconcileBank>;
101
+ createGeneralLedgerReconcileBank(payload: Partial<GeneralLedgerReconcileBank>): Promise<string | string[]>;
102
+ updateGeneralLedgerBank(bankId: string, payload: object): Promise<string>;
103
+ getAdditionalInterests(queryParams: object): Promise<AdditionalInterest[]>;
104
+ }
105
+ export type EpicServiceType = EpicService;