@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.
- package/README.md +2 -0
- package/dist/exceptions/EpicException.d.ts +3 -0
- package/dist/exceptions/EpicException.js +10 -0
- package/dist/exceptions/MissingInfo.d.ts +3 -0
- package/dist/exceptions/MissingInfo.js +10 -0
- package/dist/exceptions/NotProcessYet.d.ts +3 -0
- package/dist/exceptions/NotProcessYet.js +10 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +54 -0
- package/dist/models/admin/BusMessage.d.ts +4 -0
- package/dist/models/admin/BusMessage.js +2 -0
- package/dist/models/admin/Counter.d.ts +8 -0
- package/dist/models/admin/Counter.js +2 -0
- package/dist/models/admin/Email.d.ts +49 -0
- package/dist/models/admin/Email.js +2 -0
- package/dist/models/admin/ExcelSheet.d.ts +5 -0
- package/dist/models/admin/ExcelSheet.js +2 -0
- package/dist/models/admin/ExtractTable.d.ts +37 -0
- package/dist/models/admin/ExtractTable.js +2 -0
- package/dist/models/admin/IDictionary.d.ts +3 -0
- package/dist/models/admin/IDictionary.js +2 -0
- package/dist/models/admin/KimobyResult.d.ts +17 -0
- package/dist/models/admin/KimobyResult.js +2 -0
- package/dist/models/admin/PdfReader.d.ts +26 -0
- package/dist/models/admin/PdfReader.js +2 -0
- package/dist/models/admin/Primaco.d.ts +14 -0
- package/dist/models/admin/Primaco.js +2 -0
- package/dist/models/admin/index.d.ts +9 -0
- package/dist/models/admin/index.js +25 -0
- package/dist/models/epic/Activity.d.ts +83 -0
- package/dist/models/epic/Activity.js +2 -0
- package/dist/models/epic/AdditionalInterest.d.ts +15 -0
- package/dist/models/epic/AdditionalInterest.js +2 -0
- package/dist/models/epic/Address.d.ts +10 -0
- package/dist/models/epic/Address.js +2 -0
- package/dist/models/epic/Attachment.d.ts +47 -0
- package/dist/models/epic/Attachment.js +2 -0
- package/dist/models/epic/Broker.d.ts +38 -0
- package/dist/models/epic/Broker.js +2 -0
- package/dist/models/epic/Claim.d.ts +24 -0
- package/dist/models/epic/Claim.js +2 -0
- package/dist/models/epic/Commission.d.ts +76 -0
- package/dist/models/epic/Commission.js +2 -0
- package/dist/models/epic/Company.d.ts +9 -0
- package/dist/models/epic/Company.js +2 -0
- package/dist/models/epic/Contact.d.ts +49 -0
- package/dist/models/epic/Contact.js +2 -0
- package/dist/models/epic/Customer.d.ts +98 -0
- package/dist/models/epic/Customer.js +2 -0
- package/dist/models/epic/DirectBillCommission.d.ts +18 -0
- package/dist/models/epic/DirectBillCommission.js +2 -0
- package/dist/models/epic/Driver.d.ts +67 -0
- package/dist/models/epic/Driver.js +2 -0
- package/dist/models/epic/Employee.d.ts +145 -0
- package/dist/models/epic/Employee.js +2 -0
- package/dist/models/epic/GeneralLedgerReconcileBank.d.ts +117 -0
- package/dist/models/epic/GeneralLedgerReconcileBank.js +2 -0
- package/dist/models/epic/Habitational.d.ts +156 -0
- package/dist/models/epic/Habitational.js +2 -0
- package/dist/models/epic/Line.d.ts +169 -0
- package/dist/models/epic/Line.js +2 -0
- package/dist/models/epic/Lookup.d.ts +5 -0
- package/dist/models/epic/Lookup.js +2 -0
- package/dist/models/epic/MultiCarrierSchedule.d.ts +70 -0
- package/dist/models/epic/MultiCarrierSchedule.js +11 -0
- package/dist/models/epic/Opportunity.d.ts +45 -0
- package/dist/models/epic/Opportunity.js +2 -0
- package/dist/models/epic/OptionType.d.ts +4 -0
- package/dist/models/epic/OptionType.js +2 -0
- package/dist/models/epic/PayableContract.d.ts +19 -0
- package/dist/models/epic/PayableContract.js +2 -0
- package/dist/models/epic/Policy.d.ts +129 -0
- package/dist/models/epic/Policy.js +2 -0
- package/dist/models/epic/PolicyV2.d.ts +157 -0
- package/dist/models/epic/PolicyV2.js +2 -0
- package/dist/models/epic/Receipt.d.ts +142 -0
- package/dist/models/epic/Receipt.js +2 -0
- package/dist/models/epic/RenewalStage.d.ts +5 -0
- package/dist/models/epic/RenewalStage.js +2 -0
- package/dist/models/epic/Response.d.ts +9 -0
- package/dist/models/epic/Response.js +2 -0
- package/dist/models/epic/ServiceSummary.d.ts +16 -0
- package/dist/models/epic/ServiceSummary.js +8 -0
- package/dist/models/epic/ServicingContact.d.ts +6 -0
- package/dist/models/epic/ServicingContact.js +2 -0
- package/dist/models/epic/Transaction.d.ts +261 -0
- package/dist/models/epic/Transaction.js +2 -0
- package/dist/models/epic/Vehicle.d.ts +87 -0
- package/dist/models/epic/Vehicle.js +2 -0
- package/dist/models/epic/index.d.ts +17 -0
- package/dist/models/epic/index.js +33 -0
- package/dist/services/Admin.d.ts +30 -0
- package/dist/services/Admin.js +200 -0
- package/dist/services/BaseEpicService.d.ts +12 -0
- package/dist/services/BaseEpicService.js +102 -0
- package/dist/services/Epic.d.ts +105 -0
- package/dist/services/Epic.js +291 -0
- package/dist/services/JobEpicService.d.ts +7 -0
- package/dist/services/JobEpicService.js +16 -0
- package/dist/services/MultiCarrierScheduleEpicService.d.ts +8 -0
- package/dist/services/MultiCarrierScheduleEpicService.js +19 -0
- package/dist/utils/AxiosClient.d.ts +6 -0
- package/dist/utils/AxiosClient.js +35 -0
- package/dist/utils/DeepPartial.d.ts +3 -0
- package/dist/utils/DeepPartial.js +2 -0
- package/dist/utils/Excel.d.ts +8 -0
- package/dist/utils/Excel.js +99 -0
- package/package.json +33 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const EpicException_js_1 = require("../exceptions/EpicException.js");
|
|
4
|
+
const index_js_1 = require("../index.js");
|
|
5
|
+
class EpicService extends index_js_1.BaseEpicService {
|
|
6
|
+
constructor(epicUrl, headers) {
|
|
7
|
+
super(epicUrl, headers);
|
|
8
|
+
this.job = new index_js_1.JobEpicService(epicUrl, headers);
|
|
9
|
+
this.multiCarrierSchedule = new index_js_1.MultiCarrierScheduleEpicService(epicUrl, headers);
|
|
10
|
+
}
|
|
11
|
+
async getActivity(activityId) {
|
|
12
|
+
return this.getOne('activity', activityId);
|
|
13
|
+
}
|
|
14
|
+
async getActivities(queryParams) {
|
|
15
|
+
return this.get('activity', queryParams);
|
|
16
|
+
}
|
|
17
|
+
async updateActivity(activityId, payload) {
|
|
18
|
+
return this.put(`activity/${activityId}`, payload);
|
|
19
|
+
}
|
|
20
|
+
async createActivity(payload) {
|
|
21
|
+
return this.post(`activity`, payload);
|
|
22
|
+
}
|
|
23
|
+
async copyActivity(id, payload) {
|
|
24
|
+
return this.put(`activity/copy/${id}`, payload);
|
|
25
|
+
}
|
|
26
|
+
async getAttachments(queryParams) {
|
|
27
|
+
return this.get('attachment', queryParams);
|
|
28
|
+
}
|
|
29
|
+
async getAttachment(attachmentId) {
|
|
30
|
+
return this.getOne('attachment', attachmentId);
|
|
31
|
+
}
|
|
32
|
+
async updateAttachment(attachmentId, payload) {
|
|
33
|
+
return this.put(`attachment/${attachmentId}`, payload);
|
|
34
|
+
}
|
|
35
|
+
async createAttachment(payload) {
|
|
36
|
+
return this.post(`attachment`, payload);
|
|
37
|
+
}
|
|
38
|
+
async getAttachmentContent(attachmentId) {
|
|
39
|
+
return this.get(`attachment/download/${attachmentId}`);
|
|
40
|
+
}
|
|
41
|
+
async deleteAttachment(attachmentId) {
|
|
42
|
+
return this.delete('attachment', attachmentId);
|
|
43
|
+
}
|
|
44
|
+
async getPolicies(queryParams) {
|
|
45
|
+
return await this.get('policy', queryParams);
|
|
46
|
+
}
|
|
47
|
+
async getPolicy(id) {
|
|
48
|
+
return this.getOne('policy', id);
|
|
49
|
+
}
|
|
50
|
+
async renewPolicy(id, payload) {
|
|
51
|
+
return await this.put(`renewpolicy/${id}`, payload);
|
|
52
|
+
}
|
|
53
|
+
async updatePolicy(id, payload) {
|
|
54
|
+
return await this.put(`policy/${id}`, payload);
|
|
55
|
+
}
|
|
56
|
+
async issuePolicy(id, payload) {
|
|
57
|
+
return await this.put(`issuePolicy/${id}`, payload);
|
|
58
|
+
}
|
|
59
|
+
async cancelPolicy(id, payload) {
|
|
60
|
+
return await this.put(`cancelPolicy/${id}`, payload);
|
|
61
|
+
}
|
|
62
|
+
async createPolicy(payload) {
|
|
63
|
+
return await this.post(`policy`, payload);
|
|
64
|
+
}
|
|
65
|
+
async getPoliciesV2(queryParams) {
|
|
66
|
+
return this.get('policyV2', queryParams);
|
|
67
|
+
}
|
|
68
|
+
async getPolicyV2(id) {
|
|
69
|
+
return this.getOne('policyV2', id);
|
|
70
|
+
}
|
|
71
|
+
async createPolicyV2(payload) {
|
|
72
|
+
return this.post(`policyV2`, payload);
|
|
73
|
+
}
|
|
74
|
+
async updatePolicyV2(id, payload) {
|
|
75
|
+
return await this.put(`policyV2/${id}`, payload);
|
|
76
|
+
}
|
|
77
|
+
async renewPolicyV2(payload) {
|
|
78
|
+
const policyId = await this.post(`policyV2/renew`, payload);
|
|
79
|
+
return policyId;
|
|
80
|
+
}
|
|
81
|
+
async endorseExistingLinePolicyV2(payload) {
|
|
82
|
+
await this.put(`policyV2/endorse`, payload);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
async cancelPolicyV2(payload) {
|
|
86
|
+
return await this.put(`policyV2/cancel`, payload);
|
|
87
|
+
}
|
|
88
|
+
async issuePolicyV2(payload) {
|
|
89
|
+
await this.put(`policyV2/issue`, payload);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
async issueEndorsementPolicyV2(payload) {
|
|
93
|
+
await this.put(`policyV2/endorse/issue`, payload);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
async issueCancellationPolicyV2(payload) {
|
|
97
|
+
await this.put(`policyV2/cancel/issue`, payload);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
async getPolicyV2RenewalStages(ids) {
|
|
101
|
+
return this.get('policyV2/renewalStage', {
|
|
102
|
+
ids: ids.join(','),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
async getEmployee(id) {
|
|
106
|
+
return await this.getOne('employee', id);
|
|
107
|
+
}
|
|
108
|
+
async getEmployees(queryParams) {
|
|
109
|
+
return await this.get(`employee`, queryParams);
|
|
110
|
+
}
|
|
111
|
+
async getEmployeeV2(id) {
|
|
112
|
+
return this.getOne(`employeeV2`, id);
|
|
113
|
+
}
|
|
114
|
+
async getEmployeesV2(queryParams) {
|
|
115
|
+
return await this.get(`employeeV2`, queryParams);
|
|
116
|
+
}
|
|
117
|
+
async createEmployee(payload) {
|
|
118
|
+
return this.post(`employeeV2`, payload);
|
|
119
|
+
}
|
|
120
|
+
async updateEmployee(id, payload) {
|
|
121
|
+
return await this.put(`employeeV2/${id}`, payload);
|
|
122
|
+
}
|
|
123
|
+
async getLookUp(queryParams) {
|
|
124
|
+
return await this.get(`lookup`, queryParams);
|
|
125
|
+
}
|
|
126
|
+
async getContact(id, queryParams) {
|
|
127
|
+
return await this.getOne(`contact`, id, queryParams);
|
|
128
|
+
}
|
|
129
|
+
async getContacts(queryParams) {
|
|
130
|
+
return await this.get(`contact`, queryParams);
|
|
131
|
+
}
|
|
132
|
+
async createContact(payload) {
|
|
133
|
+
return await this.post(`contact`, payload);
|
|
134
|
+
}
|
|
135
|
+
async updateContact(id, accountType, payload) {
|
|
136
|
+
return await this.put(`contact/${id}/${accountType}`, payload);
|
|
137
|
+
}
|
|
138
|
+
async getTransactions(queryParams) {
|
|
139
|
+
return await this.get('transaction', queryParams);
|
|
140
|
+
}
|
|
141
|
+
async getTransaction(transactionId) {
|
|
142
|
+
return this.getOne('transaction', transactionId);
|
|
143
|
+
}
|
|
144
|
+
async financeTransaction(transactionId, payload) {
|
|
145
|
+
return await this.put(`transaction/finance/${transactionId}`, payload);
|
|
146
|
+
}
|
|
147
|
+
async reverseTransaction(transactionId, payload) {
|
|
148
|
+
return await this.put(`transaction/reverse/${transactionId}`, payload);
|
|
149
|
+
}
|
|
150
|
+
async transactionApplyCreditsToDebits(transactionId, payload) {
|
|
151
|
+
const { data: axiosResponse } = await this.axiosInstance.put(`transaction/applyCreditsToDebits/${transactionId}`, payload);
|
|
152
|
+
if (!axiosResponse.success) {
|
|
153
|
+
if (axiosResponse.code == '400' || axiosResponse.code == '401' || axiosResponse.code == '404') {
|
|
154
|
+
throw new EpicException_js_1.EpicException(axiosResponse.message || axiosResponse.Message);
|
|
155
|
+
}
|
|
156
|
+
throw new Error(axiosResponse.message || axiosResponse.Message);
|
|
157
|
+
}
|
|
158
|
+
return axiosResponse.result;
|
|
159
|
+
}
|
|
160
|
+
async updateTransaction(transactionId, payload) {
|
|
161
|
+
return await this.put(`transaction/${transactionId}`, payload);
|
|
162
|
+
}
|
|
163
|
+
async createTransaction(payload) {
|
|
164
|
+
return await this.post(`transaction`, payload);
|
|
165
|
+
}
|
|
166
|
+
async createPaymentTransaction(payload) {
|
|
167
|
+
return await this.post(`paymentTransaction`, payload);
|
|
168
|
+
}
|
|
169
|
+
async getCompany(companyId) {
|
|
170
|
+
return await this.getOne(`company`, companyId);
|
|
171
|
+
}
|
|
172
|
+
async getCompanies(queryParams) {
|
|
173
|
+
return await this.get(`company`, queryParams);
|
|
174
|
+
}
|
|
175
|
+
async getCustomers(queryParams) {
|
|
176
|
+
return await this.get('customer', queryParams);
|
|
177
|
+
}
|
|
178
|
+
async getCustomer(clientId) {
|
|
179
|
+
return this.getOne('customer', clientId);
|
|
180
|
+
}
|
|
181
|
+
async updateCustomer(clientId, payload) {
|
|
182
|
+
return await this.put(`customer/${clientId}`, payload);
|
|
183
|
+
}
|
|
184
|
+
async createCustomer(payload) {
|
|
185
|
+
return await this.post(`customer`, payload);
|
|
186
|
+
}
|
|
187
|
+
async getHabitationals(queryParams) {
|
|
188
|
+
return await this.get('habitational', queryParams);
|
|
189
|
+
}
|
|
190
|
+
async getCommissions(commissionId, queryParams) {
|
|
191
|
+
return this.getOne('commission', commissionId, queryParams);
|
|
192
|
+
}
|
|
193
|
+
async getCommission(commissionId) {
|
|
194
|
+
return this.getOne('commission', commissionId);
|
|
195
|
+
}
|
|
196
|
+
async getOpportunity(opportunityId) {
|
|
197
|
+
return this.getOne('opportunity', opportunityId);
|
|
198
|
+
}
|
|
199
|
+
async getOpportunities(queryParams) {
|
|
200
|
+
return this.get('opportunity', queryParams);
|
|
201
|
+
}
|
|
202
|
+
async updateOpportunity(opportunityId, payload) {
|
|
203
|
+
return this.put(`opportunity/${opportunityId}`, payload);
|
|
204
|
+
}
|
|
205
|
+
async createOpportunity(payload) {
|
|
206
|
+
return this.post(`opportunity`, payload);
|
|
207
|
+
}
|
|
208
|
+
async getClaim(claimId) {
|
|
209
|
+
return this.getOne('claim', claimId);
|
|
210
|
+
}
|
|
211
|
+
async getClaims(queryParams) {
|
|
212
|
+
return this.get('claim', queryParams);
|
|
213
|
+
}
|
|
214
|
+
async getPersonalAutoVehicles(queryParams) {
|
|
215
|
+
return this.get('personalAuto/vehicle', queryParams);
|
|
216
|
+
}
|
|
217
|
+
async getPersonalAutoDrivers(queryParams) {
|
|
218
|
+
return this.get('personalAuto/driver', queryParams);
|
|
219
|
+
}
|
|
220
|
+
async getCommercialAutoVehicles(queryParams) {
|
|
221
|
+
return this.get('commercialAuto/vehicle', queryParams);
|
|
222
|
+
}
|
|
223
|
+
async getCommercialAutoDrivers(queryParams) {
|
|
224
|
+
return this.get('commercialAuto/driver', queryParams);
|
|
225
|
+
}
|
|
226
|
+
async getPolicyLine(lineId) {
|
|
227
|
+
return this.getOne('policyLine', lineId);
|
|
228
|
+
}
|
|
229
|
+
async getPolicyLines(queryParams) {
|
|
230
|
+
return this.get('policyLine', queryParams);
|
|
231
|
+
}
|
|
232
|
+
async createPolicyLine(policyLine) {
|
|
233
|
+
return this.post('policyLine', policyLine);
|
|
234
|
+
}
|
|
235
|
+
async updatePolicyLine(lineId, payload) {
|
|
236
|
+
return this.put(`policyLine/${lineId}`, payload);
|
|
237
|
+
}
|
|
238
|
+
async getDirectBillCommission(commissionId) {
|
|
239
|
+
return this.getOne('directBillCommission', commissionId);
|
|
240
|
+
}
|
|
241
|
+
async getDirectBillCommissions(queryParams) {
|
|
242
|
+
return this.get('directBillCommission', queryParams);
|
|
243
|
+
}
|
|
244
|
+
async updateDirectBillCommission(commissionId, payload) {
|
|
245
|
+
return await this.put(`directBillCommission/${commissionId}`, payload);
|
|
246
|
+
}
|
|
247
|
+
async getReceipts(queryParams) {
|
|
248
|
+
return await this.get('receipt', queryParams);
|
|
249
|
+
}
|
|
250
|
+
async getReceipt(receiptId) {
|
|
251
|
+
return this.getOne('receipt', receiptId);
|
|
252
|
+
}
|
|
253
|
+
async updateReceipt(receiptId, payload) {
|
|
254
|
+
return await this.put(`receipt/${receiptId}`, payload);
|
|
255
|
+
}
|
|
256
|
+
async createReceipt(payload) {
|
|
257
|
+
return await this.post(`receipt`, payload);
|
|
258
|
+
}
|
|
259
|
+
async receiptApplyCreditsToDebits(receiptId, payload) {
|
|
260
|
+
const { data: axiosResponse } = await this.axiosInstance.post(`receipt/${receiptId}`, payload);
|
|
261
|
+
if (!axiosResponse.success) {
|
|
262
|
+
if (axiosResponse.code == '400' || axiosResponse.code == '401' || axiosResponse.code == '404') {
|
|
263
|
+
throw new EpicException_js_1.EpicException(axiosResponse.message || axiosResponse.Message);
|
|
264
|
+
}
|
|
265
|
+
throw new Error(axiosResponse.message || axiosResponse.Message);
|
|
266
|
+
}
|
|
267
|
+
return axiosResponse.result;
|
|
268
|
+
}
|
|
269
|
+
async getPayableContracts(queryParams) {
|
|
270
|
+
return this.get(`payableContract`, queryParams);
|
|
271
|
+
}
|
|
272
|
+
async getPayableContract(payableContractId, queryParams) {
|
|
273
|
+
return this.get(`payableContract/${payableContractId}`, queryParams);
|
|
274
|
+
}
|
|
275
|
+
async getGeneralLedgerReconcileBanks(queryParams) {
|
|
276
|
+
return this.get('generalLedgerBank', queryParams);
|
|
277
|
+
}
|
|
278
|
+
async getGeneralLedgerReconcileBank(bankId) {
|
|
279
|
+
return this.getOne('generalLedgerBank', bankId);
|
|
280
|
+
}
|
|
281
|
+
async createGeneralLedgerReconcileBank(payload) {
|
|
282
|
+
return await this.post('generalLedgerBank', payload);
|
|
283
|
+
}
|
|
284
|
+
async updateGeneralLedgerBank(bankId, payload) {
|
|
285
|
+
return await this.put(`generalLedgerBank/${bankId}`, payload);
|
|
286
|
+
}
|
|
287
|
+
async getAdditionalInterests(queryParams) {
|
|
288
|
+
return this.get('personalAuto/additionalinterests', queryParams);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
exports.default = EpicService;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BaseEpicService } from "../index.js";
|
|
2
|
+
import { DirectBillCommission, Reconciliation } from "../models/epic/DirectBillCommission.js";
|
|
3
|
+
export default class JobEpicService extends BaseEpicService {
|
|
4
|
+
readonly baseUrl = "job";
|
|
5
|
+
reconcile(payload: Reconciliation): Promise<string>;
|
|
6
|
+
updateDirectBillCommission(commissionId: string, payload: Partial<DirectBillCommission>): Promise<string>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const index_js_1 = require("../index.js");
|
|
4
|
+
class JobEpicService extends index_js_1.BaseEpicService {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.baseUrl = 'job';
|
|
8
|
+
}
|
|
9
|
+
async reconcile(payload) {
|
|
10
|
+
return this.post(`${this.baseUrl}/reconcile`, payload);
|
|
11
|
+
}
|
|
12
|
+
async updateDirectBillCommission(commissionId, payload) {
|
|
13
|
+
return this.put(`${this.baseUrl}/directBillCommission/${commissionId}`, payload);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.default = JobEpicService;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseEpicService } from "../index.js";
|
|
2
|
+
import { MultiCarrierScheduleModel } from "../models/epic/MultiCarrierSchedule.js";
|
|
3
|
+
export default class MultiCarrierScheduleEpicService extends BaseEpicService {
|
|
4
|
+
readonly baseUrl = "multiCarrierSchedule";
|
|
5
|
+
getMultiCarrierSchedules(req: MultiCarrierScheduleModel.GetRequest): Promise<MultiCarrierScheduleModel.MultiCarrierSchedule[]>;
|
|
6
|
+
createMultiCarrierSchedule(req: MultiCarrierScheduleModel.CreateRequest): Promise<string>;
|
|
7
|
+
updateMultiCarrierSchedule(multiCarrierScheduleID: number, payload: MultiCarrierScheduleModel.UpdateRequest): Promise<string>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const index_js_1 = require("../index.js");
|
|
4
|
+
class MultiCarrierScheduleEpicService extends index_js_1.BaseEpicService {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.baseUrl = 'multiCarrierSchedule';
|
|
8
|
+
}
|
|
9
|
+
async getMultiCarrierSchedules(req) {
|
|
10
|
+
return this.get(this.baseUrl, req);
|
|
11
|
+
}
|
|
12
|
+
async createMultiCarrierSchedule(req) {
|
|
13
|
+
return this.post(this.baseUrl, req);
|
|
14
|
+
}
|
|
15
|
+
async updateMultiCarrierSchedule(multiCarrierScheduleID, payload) {
|
|
16
|
+
return this.put(`${this.baseUrl}/${multiCarrierScheduleID}`, payload);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.default = MultiCarrierScheduleEpicService;
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
exports.AxiosClient = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
class AxiosClient {
|
|
9
|
+
constructor(baseURL, headers) {
|
|
10
|
+
this.axiosInstance = axios_1.default.create({
|
|
11
|
+
baseURL: baseURL,
|
|
12
|
+
headers: headers,
|
|
13
|
+
});
|
|
14
|
+
this.axiosInstance.interceptors.response.use((res) => {
|
|
15
|
+
return res;
|
|
16
|
+
}, async (err) => {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const originalConfig = err.config;
|
|
19
|
+
originalConfig._retry = originalConfig._retry || 0;
|
|
20
|
+
if ((((_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.status) === 524 || ((_b = err === null || err === void 0 ? void 0 : err.response) === null || _b === void 0 ? void 0 : _b.status) === 504) && originalConfig._retry < 3) {
|
|
21
|
+
await sleep(originalConfig._retry * 10000);
|
|
22
|
+
originalConfig._retry += 1;
|
|
23
|
+
return await this.axiosInstance(originalConfig);
|
|
24
|
+
}
|
|
25
|
+
return Promise.reject(err);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
getInstance() {
|
|
29
|
+
return this.axiosInstance;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.AxiosClient = AxiosClient;
|
|
33
|
+
async function sleep(ms) {
|
|
34
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
35
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import ExcelSheet from "../models/admin/ExcelSheet.js";
|
|
2
|
+
export default class readXlsx {
|
|
3
|
+
static getFromXLSX<T>(path: string, sheetNumber: number): Promise<T[]>;
|
|
4
|
+
static getFromCSV<T>(path: string): Promise<T[]>;
|
|
5
|
+
static appendFile(array: Array<string>, fileName: string): Promise<void>;
|
|
6
|
+
static createFile(data: string[][], header: string[], fileName: string): void;
|
|
7
|
+
static createFileFromSheets(sheets: ExcelSheet[], fileName: string): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
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 xlsx_1 = __importDefault(require("xlsx"));
|
|
8
|
+
class readXlsx {
|
|
9
|
+
static async getFromXLSX(path, sheetNumber) {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const file = xlsx_1.default.readFile(path);
|
|
12
|
+
const worksheet = file.Sheets[file.SheetNames[sheetNumber]];
|
|
13
|
+
if (!worksheet) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
(_a = worksheet['!rows']) === null || _a === void 0 ? void 0 : _a.shift();
|
|
17
|
+
const range = xlsx_1.default.utils.decode_range((_b = worksheet['!ref']) !== null && _b !== void 0 ? _b : '');
|
|
18
|
+
range.s.r = 1;
|
|
19
|
+
worksheet['!ref'] = xlsx_1.default.utils.encode_range(range);
|
|
20
|
+
return xlsx_1.default.utils.sheet_to_json(file.Sheets[file.SheetNames[sheetNumber]], {
|
|
21
|
+
raw: false,
|
|
22
|
+
defval: '',
|
|
23
|
+
range: range,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
static async getFromCSV(path) {
|
|
27
|
+
const data = await CSVToJSON(path);
|
|
28
|
+
const Info = [];
|
|
29
|
+
for (let i = 1; i < data.length; i++) {
|
|
30
|
+
const temp = data[i];
|
|
31
|
+
Info.push(temp);
|
|
32
|
+
}
|
|
33
|
+
return Info;
|
|
34
|
+
}
|
|
35
|
+
static async appendFile(array, fileName) {
|
|
36
|
+
let csv = ''; // Construct a CSV row
|
|
37
|
+
for (const el of array) {
|
|
38
|
+
if (array.indexOf(el) === array.length - 1) {
|
|
39
|
+
csv += el + '\n'; // Add new line
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
csv += el + ',';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (!fs_1.default.existsSync('./result/')) {
|
|
47
|
+
fs_1.default.mkdirSync('./result/');
|
|
48
|
+
}
|
|
49
|
+
fs_1.default.appendFileSync('./result/' + fileName, csv); // Append the CSV row to the file
|
|
50
|
+
}
|
|
51
|
+
static createFile(data, header, fileName) {
|
|
52
|
+
const workbook = xlsx_1.default.utils.book_new();
|
|
53
|
+
const sheetName = 'Rapport';
|
|
54
|
+
const filePath = './result/' + fileName;
|
|
55
|
+
if (!fs_1.default.existsSync('./result/')) {
|
|
56
|
+
fs_1.default.mkdirSync('./result/');
|
|
57
|
+
}
|
|
58
|
+
// Création de la feuille avec les données
|
|
59
|
+
const worksheet = xlsx_1.default.utils.aoa_to_sheet([header, ...data]);
|
|
60
|
+
// Ajout de la feuille de calcul au classeur
|
|
61
|
+
xlsx_1.default.utils.book_append_sheet(workbook, worksheet, sheetName);
|
|
62
|
+
// Création du fichier Excel
|
|
63
|
+
xlsx_1.default.writeFile(workbook, filePath);
|
|
64
|
+
}
|
|
65
|
+
static createFileFromSheets(sheets, fileName) {
|
|
66
|
+
const filePath = './result/' + fileName;
|
|
67
|
+
if (!fs_1.default.existsSync('./result/')) {
|
|
68
|
+
fs_1.default.mkdirSync('./result/');
|
|
69
|
+
}
|
|
70
|
+
const workbook = xlsx_1.default.utils.book_new();
|
|
71
|
+
for (const sheet of sheets) {
|
|
72
|
+
// Création de la feuille avec les données
|
|
73
|
+
const worksheet = xlsx_1.default.utils.aoa_to_sheet([sheet.header, ...sheet.data]);
|
|
74
|
+
// Ajout de la feuille de calcul au classeur
|
|
75
|
+
xlsx_1.default.utils.book_append_sheet(workbook, worksheet, sheet.name);
|
|
76
|
+
}
|
|
77
|
+
// Création du fichier Excel
|
|
78
|
+
xlsx_1.default.writeFile(workbook, filePath);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.default = readXlsx;
|
|
82
|
+
async function CSVToJSON(csv) {
|
|
83
|
+
let file = fs_1.default.readFileSync(csv, 'utf8');
|
|
84
|
+
file = file.replace('\r', '');
|
|
85
|
+
const rows = file.split('\n');
|
|
86
|
+
const titles = rows[0].split(',');
|
|
87
|
+
const data = [];
|
|
88
|
+
for (let i = 1; i < rows.length; i++) {
|
|
89
|
+
if (rows[i] === '')
|
|
90
|
+
continue;
|
|
91
|
+
const elements = rows[i].split(',');
|
|
92
|
+
const temp = {};
|
|
93
|
+
for (let j = 0; j < elements.length; j++) {
|
|
94
|
+
temp[titles[j]] = elements[j];
|
|
95
|
+
}
|
|
96
|
+
data.push(temp);
|
|
97
|
+
}
|
|
98
|
+
return data;
|
|
99
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cemiar/cemiarlink-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CemiarLink SDK to access CemiarLink API services",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "rm -rf dist/ && tsc -p tsconfig.json",
|
|
13
|
+
"buildWindows": "rmdir /s /q dist & tsc -p tsconfig.json"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"author": "Cemiar",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"axios": "^1.13.5",
|
|
22
|
+
"path": "^0.12.7",
|
|
23
|
+
"xlsx": "^0.18.5"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"ts-node": "^10.9.2"
|
|
27
|
+
},
|
|
28
|
+
"overrides": {
|
|
29
|
+
"xlsx": {
|
|
30
|
+
"sheetjs": "^2.0.0"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|