@experteam-mx/ngx-services 18.1.0 → 18.3.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 (43) hide show
  1. package/esm2022/lib/apis/api-companies.service.mjs +38 -27
  2. package/esm2022/lib/apis/api-invoices.service.mjs +74 -0
  3. package/esm2022/lib/apis/api-reports.service.mjs +43 -0
  4. package/esm2022/lib/apis/api-security.service.mjs +8 -7
  5. package/esm2022/lib/apis/api-shipments.service.mjs +43 -0
  6. package/esm2022/lib/apis/models/api-companies.interfaces.mjs +1 -1
  7. package/esm2022/lib/apis/models/api-companies.types.mjs +1 -1
  8. package/esm2022/lib/apis/models/api-invoices.interfaces.mjs +2 -0
  9. package/esm2022/lib/apis/models/api-invoices.types.mjs +2 -0
  10. package/esm2022/lib/apis/models/api-reports.interfaces.mjs +2 -0
  11. package/esm2022/lib/apis/models/api-reports.types.mjs +2 -0
  12. package/esm2022/lib/apis/models/api-security.types.mjs +1 -1
  13. package/esm2022/lib/apis/models/api-shipments.types.mjs +2 -0
  14. package/esm2022/lib/apis/models/api.models.mjs +1 -1
  15. package/esm2022/lib/cypher/crypto.service.mjs +7 -6
  16. package/esm2022/lib/helpers/http.mjs +4 -4
  17. package/esm2022/lib/interceptors/api-headers.interceptor.mjs +18 -14
  18. package/esm2022/lib/interceptors/api-token.interceptor.mjs +12 -11
  19. package/esm2022/lib/interceptors/http-caching.interceptor.mjs +18 -7
  20. package/esm2022/lib/ngx-services.models.mjs +1 -1
  21. package/esm2022/lib/ngx-services.module.mjs +5 -5
  22. package/esm2022/public-api.mjs +9 -2
  23. package/fesm2022/experteam-mx-ngx-services.mjs +251 -74
  24. package/fesm2022/experteam-mx-ngx-services.mjs.map +1 -1
  25. package/lib/apis/api-companies.service.d.ts +46 -39
  26. package/lib/apis/api-invoices.service.d.ts +48 -0
  27. package/lib/apis/api-reports.service.d.ts +26 -0
  28. package/lib/apis/api-shipments.service.d.ts +26 -0
  29. package/lib/apis/models/api-companies.interfaces.d.ts +6 -193
  30. package/lib/apis/models/api-companies.types.d.ts +30 -22
  31. package/lib/apis/models/api-invoices.interfaces.d.ts +139 -0
  32. package/lib/apis/models/api-invoices.types.d.ts +44 -0
  33. package/lib/apis/models/api-reports.interfaces.d.ts +47 -0
  34. package/lib/apis/models/api-reports.types.d.ts +6 -0
  35. package/lib/apis/models/api-security.types.d.ts +0 -3
  36. package/lib/apis/models/api-shipments.types.d.ts +32 -0
  37. package/lib/apis/models/api.models.d.ts +5 -0
  38. package/lib/interceptors/api-headers.interceptor.d.ts +6 -5
  39. package/lib/interceptors/api-token.interceptor.d.ts +5 -5
  40. package/lib/interceptors/http-caching.interceptor.d.ts +8 -0
  41. package/lib/ngx-services.models.d.ts +7 -4
  42. package/package.json +9 -1
  43. package/public-api.d.ts +8 -1
@@ -25,11 +25,11 @@ class NgxServicesModule {
25
25
  ]
26
26
  };
27
27
  }
28
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: NgxServicesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
29
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.8", ngImport: i0, type: NgxServicesModule });
30
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: NgxServicesModule, providers: [provideHttpClient()] });
28
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: NgxServicesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
29
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.11", ngImport: i0, type: NgxServicesModule });
30
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: NgxServicesModule, providers: [provideHttpClient()] });
31
31
  }
32
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: NgxServicesModule, decorators: [{
32
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: NgxServicesModule, decorators: [{
33
33
  type: NgModule,
34
34
  args: [{
35
35
  providers: [provideHttpClient()]
@@ -44,7 +44,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImpor
44
44
  * @return {string} - The generated query string.
45
45
  */
46
46
  const queryString = (params) => {
47
- let queryElements = [];
47
+ const queryElements = [];
48
48
  Object.entries(params).forEach(([key, value]) => {
49
49
  if (Array.isArray(value)) {
50
50
  const arrayQuery = value
@@ -79,7 +79,7 @@ const httpParams = (params) => new HttpParams({
79
79
  */
80
80
  const pdfHeaders = (format = 'object') => {
81
81
  const headers = {
82
- 'Accept': 'application/pdf'
82
+ Accept: 'application/pdf'
83
83
  };
84
84
  return format === 'object'
85
85
  ? headers
@@ -94,7 +94,7 @@ const pdfHeaders = (format = 'object') => {
94
94
  */
95
95
  const xmlHeaders = (format = 'object') => {
96
96
  const headers = {
97
- 'Accept': 'application/xml',
97
+ Accept: 'application/xml',
98
98
  };
99
99
  return format === 'object'
100
100
  ? headers
@@ -120,7 +120,7 @@ class ApiCompaniesService {
120
120
  * Fetches the installations based on the provided query parameters.
121
121
  *
122
122
  * @param {QueryParams} params - The parameters used to filter the installations query.
123
- * @return {Observable<InstallationsData>} An observable that emits the installations data.
123
+ * @return {Observable<InstallationsOut>} An observable that emits the installation's data.
124
124
  */
125
125
  getInstallations(params) {
126
126
  return this.http.get(`${this.url}/installations`, {
@@ -131,7 +131,7 @@ class ApiCompaniesService {
131
131
  * Retrieves the installation details based on the given installation ID.
132
132
  *
133
133
  * @param {number} id - The unique identifier of the installation to retrieve.
134
- * @returns {Observable<InstallationData>} An observable of the installation details.
134
+ * @returns {Observable<InstallationOut>} An observable of the installation details.
135
135
  */
136
136
  getInstallation(id) {
137
137
  return this.http.get(`${this.url}/installations/${id}`)
@@ -141,7 +141,7 @@ class ApiCompaniesService {
141
141
  * Retrieves a list of locations based on the provided query parameters.
142
142
  *
143
143
  * @param {QueryParams} params - The parameters to use for querying locations.
144
- * @return {Observable<LocationsData>} An observable that emits the locations data.
144
+ * @return {Observable<LocationsOut>} An observable that emits the location's data.
145
145
  */
146
146
  getLocations(params) {
147
147
  return this.http.get(`${this.url}/locations`, {
@@ -152,7 +152,7 @@ class ApiCompaniesService {
152
152
  * Fetches the location details for a given location ID.
153
153
  *
154
154
  * @param {number} id - The unique identifier of the location.
155
- * @return {Observable<LocationData>} An Observable containing the location details.
155
+ * @return {Observable<LocationOut>} An Observable containing the location details.
156
156
  */
157
157
  getLocation(id) {
158
158
  return this.http.get(`${this.url}/locations/${id}`)
@@ -162,7 +162,7 @@ class ApiCompaniesService {
162
162
  * Retrieves a list of active supply entities.
163
163
  *
164
164
  * @param {QueryParams} params - The query parameters to filter supply entities.
165
- * @return {Observable<SupplyEntitiesData>} Observable emitting supply entities data.
165
+ * @return {Observable<SupplyEntitiesOut>} Observable emitting supply entities data.
166
166
  */
167
167
  getSupplyEntitiesActive(params) {
168
168
  return this.http.get(`${this.url}/supply-entities/actives`, {
@@ -173,7 +173,7 @@ class ApiCompaniesService {
173
173
  * Fetches a list of employees based on the specified query parameters.
174
174
  *
175
175
  * @param {QueryParams} params - The parameters to filter and sort the employees.
176
- * @return {Observable<EmployeesData>} An observable that emits the list of employees.
176
+ * @return {Observable<EmployeesOut>} An observable that emits the list of employees.
177
177
  */
178
178
  getEmployees(params) {
179
179
  return this.http.get(`${this.url}/employees`, {
@@ -184,7 +184,7 @@ class ApiCompaniesService {
184
184
  * Fetches an employee's details based on the provided employee ID.
185
185
  *
186
186
  * @param {number} id - The unique identifier of the employee.
187
- * @return {Observable<EmployeeData>} An observable that emits the employee's details.
187
+ * @return {Observable<EmployeeOut>} An observable that emits the employee's details.
188
188
  */
189
189
  getEmployee(id) {
190
190
  return this.http.get(`${this.url}/employees/${id}`)
@@ -194,7 +194,7 @@ class ApiCompaniesService {
194
194
  * Retrieves the list of employees for a specified location based on provided query parameters.
195
195
  *
196
196
  * @param {QueryParams} params - The query parameters used to filter and retrieve the location employees.
197
- * @returns {Observable<LocationEmployeesData>} An observable that emits the list of employees for the specified location.
197
+ * @returns {Observable<LocationEmployeesOut>} An observable that emits the list of employees for the specified location.
198
198
  */
199
199
  getLocationEmployees(params) {
200
200
  return this.http.get(`${this.url}/location-employees`, {
@@ -205,7 +205,7 @@ class ApiCompaniesService {
205
205
  * Retrieves a list of countries where the company operates.
206
206
  *
207
207
  * @param {QueryParams} params - The query parameters for the API request.
208
- * @return {Observable<CompanyCountriesData>} An observable containing the list of company countries.
208
+ * @return {Observable<CompanyCountriesOut>} An observable containing the list of company countries.
209
209
  */
210
210
  getCompanyCountries(params) {
211
211
  return this.http.get(`${this.url}/company-countries`, {
@@ -216,7 +216,7 @@ class ApiCompaniesService {
216
216
  * Retrieves the country information for a specified company by its ID.
217
217
  *
218
218
  * @param {number} id - The unique identifier of the company.
219
- * @return {Observable<CompanyCountryData>} An observable containing the country information of the company.
219
+ * @return {Observable<CompanyCountryOut>} An observable containing the country information of the company.
220
220
  */
221
221
  getCompanyCountry(id) {
222
222
  return this.http.get(`${this.url}/company-countries/${id}`)
@@ -226,7 +226,7 @@ class ApiCompaniesService {
226
226
  * Fetches the reference currencies for a given country.
227
227
  *
228
228
  * @param {QueryParams} params - The query parameters to include in the request.
229
- * @return {Observable<CountryReferenceCurrenciesData>} The observable containing the country reference currencies data.
229
+ * @return {Observable<CountryReferenceCurrenciesOut>} The observable containing the country reference currencies data.
230
230
  */
231
231
  getCountryReferenceCurrencies(params) {
232
232
  return this.http.get(`${this.url}/country-reference-currencies`, { params }).pipe(map(({ data }) => data));
@@ -241,21 +241,32 @@ class ApiCompaniesService {
241
241
  return this.getCountryReferenceCurrencies(params)
242
242
  .pipe(mergeMap((currenciesData) => {
243
243
  const $observables = currenciesData.country_reference_currencies
244
- .map((country_reference_currency) => this.getCurrentExchanges({
245
- currency_id: country_reference_currency.currency.id,
244
+ .map((item) => this.getCurrentExchanges({
245
+ currency_id: item.currency.id,
246
246
  }).pipe(map((exchangesData) => ({
247
- ...country_reference_currency,
248
- rate: exchangesData.exchanges[0]?.value ?? 1.00,
247
+ ...item,
248
+ rate: exchangesData.exchanges[0]?.value,
249
249
  }))));
250
250
  return forkJoin($observables);
251
251
  }));
252
252
  }
253
+ /**
254
+ * Fetches exchange data based on the provided query parameters.
255
+ *
256
+ * @param {QueryParams} params - The query parameters for retrieving exchange data.
257
+ * @return {Observable<CountryExchangesOut>} An observable containing the exchange data.
258
+ */
259
+ getExchanges(params) {
260
+ return this.http.get(`${this.url}/exchanges`, {
261
+ params: httpParams(params),
262
+ }).pipe(map(({ data }) => data));
263
+ }
253
264
  /**
254
265
  * Retrieves the current exchanges based on the given query parameters.
255
266
  *
256
267
  * @param {QueryParams} params - The query parameters to filter the exchanges.
257
268
  *
258
- * @returns {Observable<ExchangesData>} - An observable that emits the API response data containing the current exchanges.
269
+ * @returns {Observable<ExchangesOut>} - An observable that emits the API response data containing the current exchanges.
259
270
  */
260
271
  getCurrentExchanges(params) {
261
272
  return this.http.get(`${this.url}/exchanges/current`, {
@@ -266,7 +277,7 @@ class ApiCompaniesService {
266
277
  * Fetches the country-specific tax information for a company.
267
278
  *
268
279
  * @param {QueryParams} params - The parameters used to filter and query the taxes.
269
- * @return {Observable<CompanyCountryTaxesData>} An observable that emits the tax information.
280
+ * @return {Observable<CompanyCountryTaxesOut>} An observable that emits the tax information.
270
281
  */
271
282
  getCompanyCountryTaxes(params) {
272
283
  return this.http.get(`${this.url}/company-country-taxes`, {
@@ -277,7 +288,7 @@ class ApiCompaniesService {
277
288
  * Retrieves the list of active account entities based on the provided query parameters.
278
289
  *
279
290
  * @param {QueryParams} params - The parameters to filter and query active account entities.
280
- * @return {Observable<AccountEntitiesData>} An observable that emits the list of active account entities.
291
+ * @return {Observable<AccountEntitiesOut>} An observable that emits the list of active account entities.
281
292
  */
282
293
  getActiveAccountEntities(params) {
283
294
  return this.http.get(`${this.url}/account-entities/actives`, {
@@ -289,7 +300,7 @@ class ApiCompaniesService {
289
300
  *
290
301
  * @param {Object} params - An object containing the required parameters.
291
302
  * @param {string[]} params.paramNames - An array of parameter names for which the values need to be fetched.
292
- * @return {Observable<ParametersData>} An observable that emits the fetched parameter values.
303
+ * @return {Observable<ParametersOut>} An observable that emits the fetched parameter values.
293
304
  */
294
305
  getParameters({ paramNames, }) {
295
306
  const parameters = paramNames.map((p) => ({ name: p }));
@@ -302,7 +313,7 @@ class ApiCompaniesService {
302
313
  *
303
314
  * @param {Object} input - The input object containing the parameter details.
304
315
  * @param {string} input.paramName - The name of the parameter whose value is to be retrieved.
305
- * @return {Observable<ParameterValueData>} An observable emitting the value of the specified parameter.
316
+ * @return {Observable<ParameterValueOut>} An observable emitting the value of the specified parameter.
306
317
  */
307
318
  getParameterValue({ paramName, }) {
308
319
  return this.http.get(`${this.url}/parameters-values/${paramName}`)
@@ -312,7 +323,7 @@ class ApiCompaniesService {
312
323
  * Retrieves a list of country references based on the given query parameters.
313
324
  *
314
325
  * @param {QueryParams} params - The query parameters for retrieving country references.
315
- * @return {Observable<CountryReferencesData>} An observable containing the country reference data.
326
+ * @return {Observable<CountryReferencesOut>} An observable containing the country reference data.
316
327
  */
317
328
  getCountryReferences(params) {
318
329
  return this.http.get(`${this.url}/country-references`, {
@@ -323,7 +334,7 @@ class ApiCompaniesService {
323
334
  * Fetches the country reference data for a given country ID.
324
335
  *
325
336
  * @param {number} id - The unique identifier of the country for which the reference data is to be retrieved.
326
- * @return {Observable<CountryReferenceData>} An observable containing the country reference data.
337
+ * @return {Observable<CountryReferenceOut>} An observable containing the country reference data.
327
338
  */
328
339
  getCountryReference(id) {
329
340
  return this.http.get(`${this.url}/country-references/${id}`)
@@ -333,17 +344,126 @@ class ApiCompaniesService {
333
344
  * Fetches the list of workflows based on the provided query parameters.
334
345
  *
335
346
  * @param {QueryParams} params - The query parameters used to filter workflows.
336
- * @return {Observable<WorkflowsData>} An observable containing the workflow data.
347
+ * @return {Observable<WorkflowsOut>} An observable containing the workflow data.
337
348
  */
338
349
  getWorkflows(params) {
339
350
  return this.http.get(`${this.url}/workflows`, {
340
351
  params: httpParams(params),
341
352
  }).pipe(map(({ data }) => data));
342
353
  }
343
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: ApiCompaniesService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
344
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: ApiCompaniesService, providedIn: 'root' });
354
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiCompaniesService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
355
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiCompaniesService, providedIn: 'root' });
356
+ }
357
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiCompaniesService, decorators: [{
358
+ type: Injectable,
359
+ args: [{
360
+ providedIn: 'root'
361
+ }]
362
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
363
+ type: Inject,
364
+ args: ['env']
365
+ }] }, { type: i1.HttpClient }] });
366
+
367
+ class ApiInvoicesService {
368
+ environments;
369
+ http;
370
+ constructor(environments, http) {
371
+ this.environments = environments;
372
+ this.http = http;
373
+ }
374
+ /**
375
+ * Retrieves the API URL for invoices from the environments configuration.
376
+ *
377
+ * @return {string} The API URL for invoices.
378
+ */
379
+ get url() {
380
+ return this.environments.apiInvoicesUrl;
381
+ }
382
+ /**
383
+ * Fetches and returns the collection receipt data for a given collection ID.
384
+ *
385
+ * @param {number} id - The unique identifier of the collection for which the receipt needs to be retrieved.
386
+ * @return {Observable<CollectionReceiptOut>} An observable containing the collection receipt data.
387
+ */
388
+ printCollectionReceipt(id) {
389
+ return this.http.get(`${this.url}/operation/print/collection-receipt/${id}`)
390
+ .pipe(map(({ data }) => data));
391
+ }
392
+ /**
393
+ * Handles the account payment operation by sending a POST request to the specified endpoint.
394
+ * Processes the response and returns the operation data.
395
+ *
396
+ * @param {AccountPaymentOperationIn} body The payload containing information for the account payment operation.
397
+ * @return {Observable<AccountPaymentOperationOut>} An observable emitting the processed account payment operation data.
398
+ */
399
+ accountPaymentOperation(body) {
400
+ return this.http.post(`${this.url}/operation/account-payment`, body)
401
+ .pipe(map(({ data }) => data));
402
+ }
403
+ /**
404
+ * Cancels a payment receipt based on the provided input.
405
+ * This method sends a POST request to cancel a document.
406
+ *
407
+ * @param body The data required to cancel the payment receipt, encapsulated in a CancelPaymentReceiptIn object.
408
+ * @return An Observable representing the result of the cancellation. Emits an empty object on success.
409
+ */
410
+ cancelPaymentReceipt(body) {
411
+ return this.http.post(`${this.url}/operation/cancel-document`, body)
412
+ .pipe(map(({ data }) => data));
413
+ }
414
+ /**
415
+ * Cancels an invoice based on the provided invoice ID and additional parameters.
416
+ *
417
+ * @param {Object} parameters - The parameters required to cancel the invoice, encapsulated in a CancelBillingIn object.
418
+ * @return {Observable<Object>} An observable that emits the response of the cancellation operation.
419
+ */
420
+ cancelInvoice({ invoiceId, ...body }) {
421
+ return this.http.post(`${this.url}/operation/cancel-billing/${invoiceId}`, body)
422
+ .pipe(map(({ data }) => data));
423
+ }
424
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiInvoicesService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
425
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiInvoicesService, providedIn: 'root' });
345
426
  }
346
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: ApiCompaniesService, decorators: [{
427
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiInvoicesService, decorators: [{
428
+ type: Injectable,
429
+ args: [{
430
+ providedIn: 'root'
431
+ }]
432
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
433
+ type: Inject,
434
+ args: ['env']
435
+ }] }, { type: i1.HttpClient }] });
436
+
437
+ class ApiReportsService {
438
+ environments;
439
+ http;
440
+ constructor(environments, http) {
441
+ this.environments = environments;
442
+ this.http = http;
443
+ }
444
+ /**
445
+ * Retrieves the URL for the reports API from the environment configurations.
446
+ *
447
+ * @return {string} The URL of the reports API.
448
+ */
449
+ get url() {
450
+ return this.environments.apiReportsUrl;
451
+ }
452
+ /**
453
+ * Retrieves the list of collection payments
454
+ *
455
+ * @param {QueryParams} params - The query parameters used to fetch the collection payments.
456
+ * @return {Observable<CollectionPaymentsOut[]>} An observable that emits an array of collection payment.
457
+ */
458
+ getCollectionPayments(params) {
459
+ return this.http.get(`${this.url}/collection-payment`, {
460
+ params
461
+ }).pipe(map(({ data }) => data));
462
+ }
463
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiReportsService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
464
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiReportsService, providedIn: 'root' });
465
+ }
466
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiReportsService, decorators: [{
347
467
  type: Injectable,
348
468
  args: [{
349
469
  providedIn: 'root'
@@ -385,7 +505,7 @@ class ApiSecurityService {
385
505
  username,
386
506
  password,
387
507
  role,
388
- }).pipe(map(({ data }) => data), tap(({ access_token }) => this.cookie.set(this.environments.tokenName, access_token, { path: '/' })));
508
+ }).pipe(map(({ data }) => data), tap(({ access_token }) => this.cookie.set(this.environments.authCookie, access_token, { path: '/' })));
389
509
  }
390
510
  /**
391
511
  * Logs out the current user by making a POST request to the logout endpoint.
@@ -396,7 +516,7 @@ class ApiSecurityService {
396
516
  */
397
517
  logout() {
398
518
  return this.http.post(`${this.url}/auth/logout`, null)
399
- .pipe(map(({ data }) => data), tap(() => this.cookie.deleteAll('/')));
519
+ .pipe(map(({ data }) => data), tap(() => this.cookie.delete(this.environments.authCookie, '/')));
400
520
  }
401
521
  /**
402
522
  * Creates a new session for a specified model.
@@ -410,8 +530,9 @@ class ApiSecurityService {
410
530
  */
411
531
  createSession({ modelType, modelId, token, }) {
412
532
  let headers = new HttpHeaders({});
413
- if (token)
533
+ if (token) {
414
534
  headers = headers.set('Authorization', `Bearer ${token}`);
535
+ }
415
536
  return this.http.post(`${this.url}/sessions`, {
416
537
  model_type: modelType,
417
538
  model_id: modelId,
@@ -465,10 +586,10 @@ class ApiSecurityService {
465
586
  language_id: languageId
466
587
  }).pipe(map(({ data }) => data));
467
588
  }
468
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: ApiSecurityService, deps: [{ token: 'env' }, { token: i1$1.CookieService }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
469
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: ApiSecurityService, providedIn: 'root' });
589
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiSecurityService, deps: [{ token: 'env' }, { token: i1$1.CookieService }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
590
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiSecurityService, providedIn: 'root' });
470
591
  }
471
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: ApiSecurityService, decorators: [{
592
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiSecurityService, decorators: [{
472
593
  type: Injectable,
473
594
  args: [{
474
595
  providedIn: 'root'
@@ -478,6 +599,45 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImpor
478
599
  args: ['env']
479
600
  }] }, { type: i1$1.CookieService }, { type: i1.HttpClient }] });
480
601
 
602
+ class ApiShipmentsService {
603
+ environments;
604
+ http;
605
+ constructor(environments, http) {
606
+ this.environments = environments;
607
+ this.http = http;
608
+ }
609
+ /**
610
+ * Retrieves the URL for the shipments API from the environment configurations.
611
+ *
612
+ * @return {string} The URL of the shipments API.
613
+ */
614
+ get url() {
615
+ return this.environments.apiShipmentUrl;
616
+ }
617
+ /**
618
+ * Retrieves the parameter values based on the provided parameter names.
619
+ *
620
+ * @param {ValidateAccountIn} body - An object of parameter names for which the values need to be fetched.
621
+ * @return {Observable<ValidateAccountIn>} An observable that emits the fetched parameter values
622
+ * @param body
623
+ */
624
+ validateAccount(body) {
625
+ return this.http.post(`${this.url}/accounts`, body)
626
+ .pipe(map(({ data }) => data));
627
+ }
628
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiShipmentsService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
629
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiShipmentsService, providedIn: 'root' });
630
+ }
631
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiShipmentsService, decorators: [{
632
+ type: Injectable,
633
+ args: [{
634
+ providedIn: 'root'
635
+ }]
636
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
637
+ type: Inject,
638
+ args: ['env']
639
+ }] }, { type: i1.HttpClient }] });
640
+
481
641
  class CryptoService {
482
642
  environments;
483
643
  constructor(environments) {
@@ -500,15 +660,16 @@ class CryptoService {
500
660
  async decryptAES(payload) {
501
661
  // Extract the Initialization Vector (IV), and the cypher text
502
662
  const [base64IV, base64Ciphertext] = payload.split(':');
503
- if (!base64IV || !base64Ciphertext)
663
+ if (!base64IV || !base64Ciphertext) {
504
664
  throw new Error('The payload must contain the IV and the cipher text.');
665
+ }
505
666
  const cryptoKey = await this.loadKey();
506
667
  const iv = this.base64ToUint8Array(base64IV);
507
668
  const cipherText = this.base64ToArrayBuffer(base64Ciphertext);
508
669
  // Decrypt the cypher text
509
670
  const decrypted = await crypto.subtle.decrypt({
510
671
  name: 'AES-GCM',
511
- iv: iv,
672
+ iv,
512
673
  }, cryptoKey, cipherText);
513
674
  // Decode the decrypted text
514
675
  const decoder = new TextDecoder();
@@ -555,10 +716,10 @@ class CryptoService {
555
716
  }
556
717
  return bytes.buffer;
557
718
  }
558
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: CryptoService, deps: [{ token: 'env' }], target: i0.ɵɵFactoryTarget.Injectable });
559
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: CryptoService, providedIn: 'root' });
719
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CryptoService, deps: [{ token: 'env' }], target: i0.ɵɵFactoryTarget.Injectable });
720
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CryptoService, providedIn: 'root' });
560
721
  }
561
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: CryptoService, decorators: [{
722
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CryptoService, decorators: [{
562
723
  type: Injectable,
563
724
  args: [{
564
725
  providedIn: 'root'
@@ -570,32 +731,36 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImpor
570
731
 
571
732
  class ApiHeadersInterceptor {
572
733
  /**
573
- * Intercepts HTTP requests and adds common headers.
734
+ * Intercepts HTTP requests and modifies request headers to include caching, content type,
735
+ * accept language, and other HTTP-specific configurations before forwarding the request onward.
574
736
  *
575
- * @param {HttpRequest<unknown>} request - The HTTP request intercepted.
576
- * @param {HttpHandler} next - The next handler in the chain.
577
- *
578
- * @returns {Observable<HttpEvent<unknown>>} - Observable of the HTTP event after interception.
737
+ * @param {HttpRequest<unknown>} request - The HTTP request instance to be intercepted and modified.
738
+ * @param {HttpHandler} next - The next handler instance in the HTTP pipeline which processes
739
+ * the modified request and forwards it.
740
+ * @return {Observable<HttpEvent<unknown>>} An observable of the processed HTTP event.
579
741
  */
580
742
  intercept(request, next) {
581
743
  let headers = new HttpHeaders({
582
744
  'cache-control': 'max-age=0, no-cache, no-store, must-revalidate',
583
- 'expires': '0',
584
- 'pragma': 'no-cache'
745
+ expires: '0',
746
+ pragma: 'no-cache'
585
747
  });
586
- if (!request.headers.has('Content-Type'))
748
+ if (!request.headers.has('Content-Type')) {
587
749
  headers = headers.set('Content-Type', 'application/json');
588
- if (!request.headers.has('Accept'))
750
+ }
751
+ if (!request.headers.has('Accept')) {
589
752
  headers = headers.set('Accept', 'application/json');
590
- if (!request.headers.has('Accept-Language'))
753
+ }
754
+ if (!request.headers.has('Accept-Language')) {
591
755
  headers = headers.set('Accept-Language', localStorage.getItem('lang') ?? 'en');
756
+ }
592
757
  request = request.clone({ headers });
593
758
  return next.handle(request);
594
759
  }
595
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: ApiHeadersInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
596
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: ApiHeadersInterceptor });
760
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiHeadersInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
761
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiHeadersInterceptor });
597
762
  }
598
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: ApiHeadersInterceptor, decorators: [{
763
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiHeadersInterceptor, decorators: [{
599
764
  type: Injectable
600
765
  }] });
601
766
 
@@ -607,17 +772,18 @@ class ApiTokenInterceptor {
607
772
  this.cookie = cookie;
608
773
  }
609
774
  /**
610
- * Intercepts the HTTP request and adds the Authorization header.
611
- *
612
- * @param {HttpRequest<unknown>} request - The HTTP request to intercept.
613
- * @param {HttpHandler} next - The next HTTP handler in the chain.
775
+ * Intercepts and modifies the outgoing HTTP request to include an authorization token
776
+ * from cookies if the request does not already have an Authorization or AppKey header.
614
777
  *
615
- * @returns {Observable<HttpEvent<unknown>>} - An observable containing the HTTP event.
778
+ * @param {HttpRequest<unknown>} request - The outgoing HTTP request to be intercepted.
779
+ * @param {HttpHandler} next - The next handler in the HTTP request processing chain.
780
+ * @return {Observable<HttpEvent<unknown>>} An observable of the HTTP event, modified or unmodified.
616
781
  */
617
782
  intercept(request, next) {
618
- if (request.headers.has('Authorization'))
783
+ if (request.headers.has('Authorization') || request.headers.has('AppKey')) {
619
784
  return next.handle(request);
620
- const token = this.cookie.get(this.environments.tokenName);
785
+ }
786
+ const token = this.cookie.get(this.environments.authCookie);
621
787
  if (!token)
622
788
  return next.handle(request);
623
789
  request = request.clone({
@@ -627,10 +793,10 @@ class ApiTokenInterceptor {
627
793
  });
628
794
  return next.handle(request);
629
795
  }
630
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: ApiTokenInterceptor, deps: [{ token: 'env' }, { token: i1$1.CookieService }], target: i0.ɵɵFactoryTarget.Injectable });
631
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: ApiTokenInterceptor });
796
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiTokenInterceptor, deps: [{ token: 'env' }, { token: i1$1.CookieService }], target: i0.ɵɵFactoryTarget.Injectable });
797
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiTokenInterceptor });
632
798
  }
633
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: ApiTokenInterceptor, decorators: [{
799
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiTokenInterceptor, decorators: [{
634
800
  type: Injectable
635
801
  }], ctorParameters: () => [{ type: undefined, decorators: [{
636
802
  type: Inject,
@@ -644,27 +810,38 @@ class HttpCachingInterceptor {
644
810
  constructor(envs) {
645
811
  this.envs = envs;
646
812
  }
813
+ /**
814
+ * Intercepts HTTP requests to add caching functionality for GET requests.
815
+ * Non-GET requests are passed through without caching.
816
+ *
817
+ * @param {HttpRequest<any>} req - The HTTP request being intercepted.
818
+ * @param {HttpHandler} next - The next handler in the HTTP pipeline to execute the request.
819
+ * @return {Observable<HttpEvent<any>>} - An observable containing the HTTP response event, either from cache or the backend service.
820
+ */
647
821
  intercept(req, next) {
648
- if (req.method !== 'GET')
822
+ if (req.method !== 'GET') {
649
823
  return next.handle(req);
824
+ }
650
825
  const cached = this.cache.get(req.urlWithParams);
651
826
  if (cached) {
652
827
  const isExpired = Date.now() > cached.ttl;
653
- if (!isExpired)
828
+ if (!isExpired) {
654
829
  return of(cached.res);
830
+ }
655
831
  this.cache.delete(req.urlWithParams); // If expired, remove the entry from cache
656
832
  }
657
833
  return next.handle(req).pipe(tap$1((res) => {
658
- if (!(res instanceof HttpResponse))
834
+ if (!(res instanceof HttpResponse)) {
659
835
  return;
836
+ }
660
837
  const ttl = Date.now() + (this.envs.cacheTtl ?? DEFAULT_TTL);
661
838
  this.cache.set(req.urlWithParams, { res, ttl });
662
839
  }));
663
840
  }
664
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: HttpCachingInterceptor, deps: [{ token: 'env' }], target: i0.ɵɵFactoryTarget.Injectable });
665
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: HttpCachingInterceptor });
841
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: HttpCachingInterceptor, deps: [{ token: 'env' }], target: i0.ɵɵFactoryTarget.Injectable });
842
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: HttpCachingInterceptor });
666
843
  }
667
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: HttpCachingInterceptor, decorators: [{
844
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: HttpCachingInterceptor, decorators: [{
668
845
  type: Injectable
669
846
  }], ctorParameters: () => [{ type: undefined, decorators: [{
670
847
  type: Inject,
@@ -679,5 +856,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImpor
679
856
  * Generated bundle index. Do not edit.
680
857
  */
681
858
 
682
- export { ApiCompaniesService, ApiHeadersInterceptor, ApiSecurityService, ApiTokenInterceptor, CryptoService, HttpCachingInterceptor, NgxServicesModule, httpParams, pdfHeaders, queryString, xmlHeaders };
859
+ export { ApiCompaniesService, ApiHeadersInterceptor, ApiInvoicesService, ApiReportsService, ApiSecurityService, ApiShipmentsService, ApiTokenInterceptor, CryptoService, HttpCachingInterceptor, NgxServicesModule, httpParams, pdfHeaders, queryString, xmlHeaders };
683
860
  //# sourceMappingURL=experteam-mx-ngx-services.mjs.map