@experteam-mx/ngx-services 18.3.7 → 18.4.1

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 (61) hide show
  1. package/esm2022/lib/apis/api-companies.service.mjs +25 -24
  2. package/esm2022/lib/apis/api-invoices.service.mjs +12 -82
  3. package/esm2022/lib/apis/api-reports.service.mjs +5 -51
  4. package/esm2022/lib/apis/api-security.service.mjs +36 -51
  5. package/esm2022/lib/apis/api-shipments.service.mjs +6 -16
  6. package/esm2022/lib/apis/models/api-catalog.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 +1 -1
  9. package/esm2022/lib/apis/models/api-invoices.types.mjs +1 -1
  10. package/esm2022/lib/apis/models/api-reports.interfaces.mjs +1 -1
  11. package/esm2022/lib/apis/models/api-reports.types.mjs +1 -1
  12. package/esm2022/lib/apis/models/api-security.types.mjs +1 -1
  13. package/esm2022/lib/apis/models/api-shipments.types.mjs +1 -1
  14. package/esm2022/lib/cypher/crypto.service.mjs +3 -3
  15. package/esm2022/lib/interceptors/api-headers.interceptor.mjs +22 -36
  16. package/esm2022/lib/interceptors/api-token.interceptor.mjs +25 -39
  17. package/esm2022/lib/interceptors/http-caching.interceptor.mjs +30 -43
  18. package/esm2022/lib/ngx-services.models.mjs +11 -2
  19. package/esm2022/lib/ngx-services.module.mjs +4 -4
  20. package/esm2022/public-api.mjs +2 -13
  21. package/fesm2022/experteam-mx-ngx-services.mjs +232 -734
  22. package/fesm2022/experteam-mx-ngx-services.mjs.map +1 -1
  23. package/lib/apis/api-companies.service.d.ts +9 -9
  24. package/lib/apis/api-invoices.service.d.ts +9 -59
  25. package/lib/apis/api-reports.service.d.ts +1 -24
  26. package/lib/apis/api-security.service.d.ts +27 -38
  27. package/lib/apis/api-shipments.service.d.ts +3 -10
  28. package/lib/apis/models/api-catalog.interfaces.d.ts +0 -6
  29. package/lib/apis/models/api-companies.types.d.ts +13 -7
  30. package/lib/apis/models/api-invoices.interfaces.d.ts +1 -35
  31. package/lib/apis/models/api-invoices.types.d.ts +5 -57
  32. package/lib/apis/models/api-reports.interfaces.d.ts +0 -149
  33. package/lib/apis/models/api-reports.types.d.ts +4 -13
  34. package/lib/apis/models/api-security.types.d.ts +8 -8
  35. package/lib/apis/models/api-shipments.types.d.ts +0 -41
  36. package/lib/interceptors/api-headers.interceptor.d.ts +11 -16
  37. package/lib/interceptors/api-token.interceptor.d.ts +10 -20
  38. package/lib/interceptors/http-caching.interceptor.d.ts +11 -19
  39. package/lib/ngx-services.models.d.ts +31 -16
  40. package/package.json +2 -11
  41. package/public-api.d.ts +1 -10
  42. package/esm2022/lib/apis/api-billing-do.service.mjs +0 -41
  43. package/esm2022/lib/apis/api-billing-mx.service.mjs +0 -62
  44. package/esm2022/lib/apis/api-external-pickups.service.mjs +0 -72
  45. package/esm2022/lib/apis/api-open-items.service.mjs +0 -62
  46. package/esm2022/lib/apis/models/api-billing.interfaces.mjs +0 -2
  47. package/esm2022/lib/apis/models/api-billing.types.mjs +0 -2
  48. package/esm2022/lib/apis/models/api-external-pickups.types.mjs +0 -2
  49. package/esm2022/lib/apis/models/api-open-items.interfaces.mjs +0 -2
  50. package/esm2022/lib/apis/models/api-open-items.types.mjs +0 -2
  51. package/esm2022/lib/websockets/web-sockets.service.mjs +0 -115
  52. package/lib/apis/api-billing-do.service.d.ts +0 -24
  53. package/lib/apis/api-billing-mx.service.d.ts +0 -39
  54. package/lib/apis/api-external-pickups.service.d.ts +0 -45
  55. package/lib/apis/api-open-items.service.d.ts +0 -41
  56. package/lib/apis/models/api-billing.interfaces.d.ts +0 -41
  57. package/lib/apis/models/api-billing.types.d.ts +0 -17
  58. package/lib/apis/models/api-external-pickups.types.d.ts +0 -31
  59. package/lib/apis/models/api-open-items.interfaces.d.ts +0 -32
  60. package/lib/apis/models/api-open-items.types.d.ts +0 -58
  61. package/lib/websockets/web-sockets.service.d.ts +0 -49
@@ -1,12 +1,21 @@
1
1
  import * as i0 from '@angular/core';
2
- import { NgModule, Injectable, Inject } from '@angular/core';
2
+ import { InjectionToken, NgModule, Injectable, Inject, inject } from '@angular/core';
3
3
  import * as i1 from '@angular/common/http';
4
- import { provideHttpClient, HttpHeaders, HttpResponse, HttpParams } from '@angular/common/http';
5
- import { map, mergeMap, forkJoin, tap, Observable, of } from 'rxjs';
6
- import { map as map$1, tap as tap$1 } from 'rxjs/operators';
4
+ import { provideHttpClient, HttpParams, HttpHeaders, HttpResponse } from '@angular/common/http';
5
+ import { map, mergeMap, forkJoin, tap, of } from 'rxjs';
7
6
  import * as i1$1 from 'ngx-cookie-service';
8
- import Pusher__default from 'pusher-js';
9
- export * from 'pusher-js';
7
+ import { CookieService } from 'ngx-cookie-service';
8
+ import { tap as tap$1 } from 'rxjs/operators';
9
+
10
+ /**
11
+ * Injection token used to inject environment configurations.
12
+ *
13
+ * `ENVIRONMENT_TOKEN` is a dependency injection token that allows
14
+ * for the provision and retrieval of environment-specific configurations
15
+ * within the application. This token is typically associated with an
16
+ * `Environment` type that defines the structure of the configuration.
17
+ */
18
+ const ENVIRONMENT_TOKEN = new InjectionToken('Environments token');
10
19
 
11
20
  class NgxServicesModule {
12
21
  /**
@@ -27,111 +36,81 @@ class NgxServicesModule {
27
36
  ]
28
37
  };
29
38
  }
30
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: NgxServicesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
31
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.11", ngImport: i0, type: NgxServicesModule });
32
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: NgxServicesModule, providers: [provideHttpClient()] });
39
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgxServicesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
40
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.13", ngImport: i0, type: NgxServicesModule });
41
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgxServicesModule, providers: [provideHttpClient()] });
33
42
  }
34
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: NgxServicesModule, decorators: [{
43
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgxServicesModule, decorators: [{
35
44
  type: NgModule,
36
45
  args: [{
37
46
  providers: [provideHttpClient()]
38
47
  }]
39
48
  }] });
40
49
 
41
- class ApiBillingDOService {
42
- environments;
43
- http;
44
- constructor(environments, http) {
45
- this.environments = environments;
46
- this.http = http;
47
- }
48
- /**
49
- * Retrieves the URL for the shipments API from the environment configurations.
50
- *
51
- * @return {string} The URL of the shipments API.
52
- */
53
- get url() {
54
- return this.environments.apiBillingDO;
55
- }
56
- /**
57
- * Retrieves a list of income types
58
- *
59
- * @return {Observable<ApiSuccess<IncomeTypesOut>>} An observable that emits the income types data.
60
- */
61
- getIncomeTypes() {
62
- return this.http.get(`${this.url}/income-types`)
63
- .pipe(map(({ data }) => data));
64
- }
65
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiBillingDOService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
66
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiBillingDOService, providedIn: 'root' });
67
- }
68
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiBillingDOService, decorators: [{
69
- type: Injectable,
70
- args: [{
71
- providedIn: 'root'
72
- }]
73
- }], ctorParameters: () => [{ type: undefined, decorators: [{
74
- type: Inject,
75
- args: ['env']
76
- }] }, { type: i1.HttpClient }] });
77
-
78
- class ApiBillingMxService {
79
- environments;
80
- http;
81
- constructor(environments, http) {
82
- this.environments = environments;
83
- this.http = http;
84
- }
85
- /**
86
- * Retrieves the URL for the shipments API from the environment configurations.
87
- *
88
- * @return {string} The URL of the shipments API.
89
- */
90
- get url() {
91
- return this.environments.apiBillingMX;
92
- }
93
- /**
94
- * Fetches the tax regimen data from the server.
95
- *
96
- * @return {Observable<FiscalRegimensOut>} An observable that emits the fiscal regimen data.
97
- */
98
- getFiscalRegimens() {
99
- return this.http.get(`${this.url}/fiscal-regimens`)
100
- .pipe(map(({ data }) => data));
101
- }
102
- /**
103
- * Fetches a paginated list of CFDIs (Comprobante Fiscal Digital por Internet) based on the provided fiscal regimen.
104
- *
105
- * @param {number} fiscalRegimen - The fiscal regimen identifier to filter the CFDIs.
106
- * @return {Observable<FiscalRegimensAcceptedOut>} An observable containing the paginated list of CFDIs.
107
- */
108
- getFiscalRegimensAccepted(fiscalRegimen) {
109
- const params = { 'fiscal-regimen': fiscalRegimen };
110
- return this.http.get(`${this.url}/cfdi-uses/fiscal-regimen-accepted/list`, { params })
111
- .pipe(map(({ data }) => data));
112
- }
113
- /**
114
- * Fetches and validates postal code data from the server.
115
- *
116
- * @param {QueryParams} params - Query parameters used to filter the postal code data.
117
- * @return {Observable<PostalCodesOut>} - An observable emitting the validated postal code data.
118
- */
119
- getPostalCodes(params) {
120
- return this.http.get(`${this.url}/postal-codes`, { params })
121
- .pipe(map(({ data }) => data));
122
- }
123
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiBillingMxService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
124
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiBillingMxService, providedIn: 'root' });
125
- }
126
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiBillingMxService, decorators: [{
127
- type: Injectable,
128
- args: [{
129
- providedIn: 'root'
130
- }]
131
- }], ctorParameters: () => [{ type: undefined, decorators: [{
132
- type: Inject,
133
- args: ['env']
134
- }] }, { type: i1.HttpClient }] });
50
+ /**
51
+ * Convert an object of key-value pairs into a URL query string.
52
+ *
53
+ * @param {Object} params - The key-value pairs to converted into a query string.
54
+ *
55
+ * @return {string} - The generated query string.
56
+ */
57
+ const queryString = (params) => {
58
+ const queryElements = [];
59
+ Object.entries(params).forEach(([key, value]) => {
60
+ if (Array.isArray(value)) {
61
+ const arrayQuery = value
62
+ .map((item) => `${encodeURIComponent(key)}=${encodeURIComponent(item)}`)
63
+ .join('&');
64
+ queryElements.push(arrayQuery);
65
+ }
66
+ else {
67
+ const encodedQuery = `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
68
+ queryElements.push(encodedQuery);
69
+ }
70
+ });
71
+ const queryString = queryElements.join('&');
72
+ return queryString.length ? `?${queryString}` : '';
73
+ };
74
+ /**
75
+ * Creates an instance of HttpParams using the provided params object.
76
+ *
77
+ * @param {Object} params - The object containing the params to the HttpParams constructor.
78
+ *
79
+ * @returns {HttpParams} - An instance of HttpParams created from the params object.
80
+ */
81
+ const httpParams = (params) => new HttpParams({
82
+ fromObject: params
83
+ });
84
+ /**
85
+ * Returns the headers for generating PDF files.
86
+ *
87
+ * @param {string} format - The format of the headers, 'object' or 'http_header'.
88
+ *
89
+ * @returns {HttpHeaders | { [header: string]: string | string[] }} - The headers for generating PDF files.
90
+ */
91
+ const pdfHeaders = (format = 'object') => {
92
+ const headers = {
93
+ Accept: 'application/pdf'
94
+ };
95
+ return format === 'object'
96
+ ? headers
97
+ : new HttpHeaders(headers);
98
+ };
99
+ /**
100
+ * Returns the headers for generating XML files.
101
+ *
102
+ * @param {string} format - The format of the headers, 'object' or 'http_header'.
103
+ *
104
+ * @returns {HttpHeaders | { [header: string]: string | string[] }} - The headers for generating XML files.
105
+ */
106
+ const xmlHeaders = (format = 'object') => {
107
+ const headers = {
108
+ Accept: 'application/xml',
109
+ };
110
+ return format === 'object'
111
+ ? headers
112
+ : new HttpHeaders(headers);
113
+ };
135
114
 
136
115
  class ApiCompaniesService {
137
116
  environments;
@@ -146,7 +125,7 @@ class ApiCompaniesService {
146
125
  * @return {string} The URL of the companies API.
147
126
  */
148
127
  get url() {
149
- return this.environments.apiCompaniesUrl;
128
+ return this.environments.apiCompaniesUrl ?? '';
150
129
  }
151
130
  /**
152
131
  * Fetches the installations based on the provided query parameters.
@@ -156,7 +135,7 @@ class ApiCompaniesService {
156
135
  */
157
136
  getInstallations(params) {
158
137
  return this.http.get(`${this.url}/installations`, {
159
- params,
138
+ params: httpParams(params),
160
139
  }).pipe(map(({ data }) => data));
161
140
  }
162
141
  /**
@@ -177,7 +156,7 @@ class ApiCompaniesService {
177
156
  */
178
157
  getLocations(params) {
179
158
  return this.http.get(`${this.url}/locations`, {
180
- params,
159
+ params: httpParams(params),
181
160
  }).pipe(map(({ data }) => data));
182
161
  }
183
162
  /**
@@ -194,11 +173,11 @@ class ApiCompaniesService {
194
173
  * Retrieves a list of active supply entities.
195
174
  *
196
175
  * @param {QueryParams} params - The query parameters to filter supply entities.
197
- * @return {Observable<SupplyEntitiesActivesOut>} Observable emitting supply entities data.
176
+ * @return {Observable<SupplyEntitiesOut>} Observable emitting supply entities data.
198
177
  */
199
- getSupplyEntitiesActives(params) {
178
+ getSupplyEntitiesActive(params) {
200
179
  return this.http.get(`${this.url}/supply-entities/actives`, {
201
- params,
180
+ params: httpParams(params),
202
181
  }).pipe(map(({ data }) => data));
203
182
  }
204
183
  /**
@@ -209,7 +188,7 @@ class ApiCompaniesService {
209
188
  */
210
189
  getEmployees(params) {
211
190
  return this.http.get(`${this.url}/employees`, {
212
- params,
191
+ params: httpParams(params),
213
192
  }).pipe(map(({ data }) => data));
214
193
  }
215
194
  /**
@@ -230,7 +209,7 @@ class ApiCompaniesService {
230
209
  */
231
210
  getLocationEmployees(params) {
232
211
  return this.http.get(`${this.url}/location-employees`, {
233
- params,
212
+ params: httpParams(params),
234
213
  }).pipe(map(({ data }) => data));
235
214
  }
236
215
  /**
@@ -241,7 +220,7 @@ class ApiCompaniesService {
241
220
  */
242
221
  getCompanyCountries(params) {
243
222
  return this.http.get(`${this.url}/company-countries`, {
244
- params,
223
+ params: httpParams(params),
245
224
  }).pipe(map(({ data }) => data));
246
225
  }
247
226
  /**
@@ -286,11 +265,11 @@ class ApiCompaniesService {
286
265
  * Fetches exchange data based on the provided query parameters.
287
266
  *
288
267
  * @param {QueryParams} params - The query parameters for retrieving exchange data.
289
- * @return {Observable<ExchangesOut>} An observable containing the exchange data.
268
+ * @return {Observable<CountryExchangesOut>} An observable containing the exchange data.
290
269
  */
291
270
  getExchanges(params) {
292
271
  return this.http.get(`${this.url}/exchanges`, {
293
- params,
272
+ params: httpParams(params),
294
273
  }).pipe(map(({ data }) => data));
295
274
  }
296
275
  /**
@@ -302,7 +281,7 @@ class ApiCompaniesService {
302
281
  */
303
282
  getCurrentExchanges(params) {
304
283
  return this.http.get(`${this.url}/exchanges/current`, {
305
- params,
284
+ params: httpParams(params),
306
285
  }).pipe(map(({ data }) => data));
307
286
  }
308
287
  /**
@@ -313,18 +292,18 @@ class ApiCompaniesService {
313
292
  */
314
293
  getCompanyCountryTaxes(params) {
315
294
  return this.http.get(`${this.url}/company-country-taxes`, {
316
- params,
295
+ params: httpParams(params),
317
296
  }).pipe(map(({ data }) => data));
318
297
  }
319
298
  /**
320
299
  * Retrieves the list of active account entities based on the provided query parameters.
321
300
  *
322
301
  * @param {QueryParams} params - The parameters to filter and query active account entities.
323
- * @return {Observable<AccountEntitiesActivesOut>} An observable that emits the list of active account entities.
302
+ * @return {Observable<AccountEntitiesOut>} An observable that emits the list of active account entities.
324
303
  */
325
- getAccountEntitiesActives(params) {
304
+ getActiveAccountEntities(params) {
326
305
  return this.http.get(`${this.url}/account-entities/actives`, {
327
- params,
306
+ params: httpParams(params),
328
307
  }).pipe(map(({ data }) => data));
329
308
  }
330
309
  /**
@@ -332,9 +311,9 @@ class ApiCompaniesService {
332
311
  *
333
312
  * @param {Object} params - An object containing the required parameters.
334
313
  * @param {string[]} params.paramNames - An array of parameter names for which the values need to be fetched.
335
- * @return {Observable<ParametersValuesOut>} An observable that emits the fetched parameter values.
314
+ * @return {Observable<ParametersOut>} An observable that emits the fetched parameter values.
336
315
  */
337
- getParametersValues({ paramNames, }) {
316
+ getParameters({ paramNames, }) {
338
317
  const parameters = paramNames.map((p) => ({ name: p }));
339
318
  return this.http.post(`${this.url}/parameters-values`, {
340
319
  parameters
@@ -359,7 +338,7 @@ class ApiCompaniesService {
359
338
  */
360
339
  getCountryReferences(params) {
361
340
  return this.http.get(`${this.url}/country-references`, {
362
- params,
341
+ params: httpParams(params),
363
342
  }).pipe(map(({ data }) => data));
364
343
  }
365
344
  /**
@@ -380,13 +359,13 @@ class ApiCompaniesService {
380
359
  */
381
360
  getWorkflows(params) {
382
361
  return this.http.get(`${this.url}/workflows`, {
383
- params,
362
+ params: httpParams(params),
384
363
  }).pipe(map(({ data }) => data));
385
364
  }
386
- 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 });
387
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiCompaniesService, providedIn: 'root' });
365
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiCompaniesService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
366
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiCompaniesService, providedIn: 'root' });
388
367
  }
389
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiCompaniesService, decorators: [{
368
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiCompaniesService, decorators: [{
390
369
  type: Injectable,
391
370
  args: [{
392
371
  providedIn: 'root'
@@ -396,74 +375,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
396
375
  args: ['env']
397
376
  }] }, { type: i1.HttpClient }] });
398
377
 
399
- class ApiExternalPickupsService {
400
- httpClient;
401
- environment;
402
- constructor(httpClient, environment) {
403
- this.httpClient = httpClient;
404
- this.environment = environment;
405
- }
406
- /**
407
- * Getter method to retrieve the API's external operations URL.
408
- * Fetches the URL from the `apiExternalOperationsUrl` property of the environment object.
409
- * Defaults to an empty string if the property is undefined or null.
410
- *
411
- * @return {string} The external operations URL or an empty string if unavailable.
412
- */
413
- get url() {
414
- return this.environment.apiExternalOperationsUrl ?? '';
415
- }
416
- /**
417
- * Generates a delivery confirmation by sending the provided payload to the API.
418
- *
419
- * @param {DeliveryConfirmationGenerateIn} payload - The input payload required to generate the delivery confirmation.
420
- * @return {Observable<DeliveryConfirmationGenerateOut>} An observable that emits the generated delivery confirmation data.
421
- */
422
- postDeliveryConfirmationGenerate(payload) {
423
- return this.httpClient.post(`${this.url}/delivery-confirmation/generate`, payload, {
424
- headers: { appkey: this.environment.apiExternalOperationsKey }
425
- }).pipe(map$1(({ data }) => data));
426
- }
427
- /**
428
- * Confirms the completion of a delivery operation by making a PATCH request.
429
- *
430
- * @param {Object} input - The input parameters for the method.
431
- * @param {string} input.operationId - The unique identifier of the delivery operation to be confirmed.
432
- * @param {string} input.keyOTP - The one-time password (OTP) key associated with the delivery confirmation.
433
- * @return {Observable<Object>} - An observable containing the response data from the API.
434
- */
435
- patchDeliveryConfirmationComplete({ keyOTP, operationId, }) {
436
- return this.httpClient.patch(`${this.url}/delivery-confirmation/completed/${keyOTP}`, null, {
437
- headers: { appkey: this.environment.apiExternalOperationsKey },
438
- params: { operation_id: operationId }
439
- }).pipe(map$1(({ data }) => data));
440
- }
441
- /**
442
- * Cancels a delivery confirmation by sending an OTP and additional data to the server.
443
- *
444
- * @param {Object} param0 - The parameter object containing the required properties.
445
- * @param {string} param0.otp - The one-time password to authenticate the cancellation request.
446
- * @param {Object} param0.body - Additional body data required for cancellation.
447
- * @return {Observable<Object>} An observable that emits the server's response when the cancellation is processed.
448
- */
449
- putDeliveryConfirmation({ otp, ...body }) {
450
- return this.httpClient.put(`${this.url}/delivery-confirmation/confirmation/${otp}`, body, {
451
- headers: { appkey: this.environment.apiExternalOperationsKey },
452
- }).pipe(map$1(({ data }) => data));
453
- }
454
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiExternalPickupsService, deps: [{ token: i1.HttpClient }, { token: 'env' }], target: i0.ɵɵFactoryTarget.Injectable });
455
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiExternalPickupsService, providedIn: 'root' });
456
- }
457
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiExternalPickupsService, decorators: [{
458
- type: Injectable,
459
- args: [{
460
- providedIn: 'root'
461
- }]
462
- }], ctorParameters: () => [{ type: i1.HttpClient }, { type: undefined, decorators: [{
463
- type: Inject,
464
- args: ['env']
465
- }] }] });
466
-
467
378
  class ApiInvoicesService {
468
379
  environments;
469
380
  http;
@@ -477,25 +388,15 @@ class ApiInvoicesService {
477
388
  * @return {string} The API URL for invoices.
478
389
  */
479
390
  get url() {
480
- return this.environments.apiInvoicesUrl;
481
- }
482
- /**
483
- * Sends an operation document to the server and processes the response.
484
- *
485
- * @param {OperationDocumentIn} body - The input data for the operation document.
486
- * @return {Observable<OperationDocumentOut>} An observable containing the processed operation document output.
487
- */
488
- postOperationDocument(body) {
489
- return this.http.post(`${this.url}/operation/document`, body)
490
- .pipe(map(({ data }) => data));
391
+ return this.environments.apiInvoicesUrl ?? '';
491
392
  }
492
393
  /**
493
394
  * Fetches and returns the collection receipt data for a given collection ID.
494
395
  *
495
396
  * @param {number} id - The unique identifier of the collection for which the receipt needs to be retrieved.
496
- * @return {Observable<PrintCollectionReceiptOut>} An observable containing the collection receipt data.
397
+ * @return {Observable<CollectionReceiptOut>} An observable containing the collection receipt data.
497
398
  */
498
- getPrintCollectionReceipt(id) {
399
+ printCollectionReceipt(id) {
499
400
  return this.http.get(`${this.url}/operation/print/collection-receipt/${id}`)
500
401
  .pipe(map(({ data }) => data));
501
402
  }
@@ -503,10 +404,10 @@ class ApiInvoicesService {
503
404
  * Handles the account payment operation by sending a POST request to the specified endpoint.
504
405
  * Processes the response and returns the operation data.
505
406
  *
506
- * @param {OperationAccountPaymentIn} body The payload containing information for the account payment operation.
507
- * @return {Observable<OperationAccountPaymentOut>} An observable emitting the processed account payment operation data.
407
+ * @param {AccountPaymentOperationIn} body The payload containing information for the account payment operation.
408
+ * @return {Observable<AccountPaymentOperationOut>} An observable emitting the processed account payment operation data.
508
409
  */
509
- postOperationAccountPayment(body) {
410
+ accountPaymentOperation(body) {
510
411
  return this.http.post(`${this.url}/operation/account-payment`, body)
511
412
  .pipe(map(({ data }) => data));
512
413
  }
@@ -517,7 +418,7 @@ class ApiInvoicesService {
517
418
  * @param body The data required to cancel the payment receipt, encapsulated in a CancelPaymentReceiptIn object.
518
419
  * @return An Observable representing the result of the cancellation. Emits an empty object on success.
519
420
  */
520
- postOperationCancelDocument(body) {
421
+ cancelPaymentReceipt(body) {
521
422
  return this.http.post(`${this.url}/operation/cancel-document`, body)
522
423
  .pipe(map(({ data }) => data));
523
424
  }
@@ -527,132 +428,14 @@ class ApiInvoicesService {
527
428
  * @param {Object} parameters - The parameters required to cancel the invoice, encapsulated in a CancelBillingIn object.
528
429
  * @return {Observable<Object>} An observable that emits the response of the cancellation operation.
529
430
  */
530
- postOperationCancelBilling({ invoiceId, ...body }) {
431
+ cancelInvoice({ invoiceId, ...body }) {
531
432
  return this.http.post(`${this.url}/operation/cancel-billing/${invoiceId}`, body)
532
433
  .pipe(map(({ data }) => data));
533
434
  }
534
- /**
535
- * Fetches a list of customer types from the server.
536
- *
537
- * @param {QueryParams} params - Query parameters to filter or customize the request.
538
- * @return {Observable<CustomerTypesOut>} An observable emitting the customer types fetched from the server.
539
- */
540
- getCustomerTypes(params) {
541
- return this.http.get(`${this.url}/customer-types`, { params })
542
- .pipe(map(({ data }) => data));
543
- }
544
- /**
545
- * Retrieves document types specific to a given country.
546
- *
547
- * @param {QueryParams} params - The query parameters containing country-specific information.
548
- * @return {Observable<CustomerDocumentTypesOut>} An observable emitting the document types available for the specified country.
549
- */
550
- getCustomerDocumentTypes(params) {
551
- return this.http.get(`${this.url}/customer-country-document-types`, { params })
552
- .pipe(map(({ data }) => data));
553
- }
554
- /**
555
- * Fetches customer invoice details filtered by a custom invoice type.
556
- *
557
- * @param {InvoiceTypeCustomParamsIn} params - An object containing the filter parameters for the custom invoice type.
558
- * @return {Observable<CustomersOut>} An observable containing customer invoice details of the specified type.
559
- */
560
- getCustomers(params) {
561
- return this.http.get(`${this.url}/customers`, { params })
562
- .pipe(map(({ data }) => data));
563
- }
564
- /**
565
- * Sends a POST request to create or update an external shipment operation.
566
- *
567
- * @param {OperationShipmentExternalIn} params - The input parameters for the external shipment operation.
568
- * @return {Observable<OperationShipmentExternalOut>} An observable that emits the result of the external shipment operation.
569
- */
570
- postOperationShipmentExternal(params) {
571
- return this.http.post(`${this.url}/operation/shipment/external`, params)
572
- .pipe(map(({ data }) => data));
573
- }
574
- /**
575
- * Processes an external payment operation for a shipment.
576
- *
577
- * @param {OperationShipmentExternalIn} params - The input parameters required for the external payment operation.
578
- * @return {Observable<OperationShipmentExternalOut>} An observable that emits the result of the external payment operation for a shipment.
579
- */
580
- postOperationShipmentExternalPayment(params) {
581
- return this.http.post(`${this.url}/operation/shipment/external/payment`, params)
582
- .pipe(map(({ data }) => data));
583
- }
584
- /**
585
- * Retrieves and returns billing operation print details for a given document ID.
586
- *
587
- * @param {number} documentId - The ID of the document for which to fetch the print billing operation details.
588
- * @return {Observable<OperationPrintDocumentOut>} An observable emitting the print billing operation details for the specified document.
589
- */
590
- getOperationPrintDocument(documentId) {
591
- return this.http.get(`${this.url}/operation/print/document/${documentId}`)
592
- .pipe(map(({ data }) => data));
593
- }
594
- 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 });
595
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiInvoicesService, providedIn: 'root' });
596
- }
597
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiInvoicesService, decorators: [{
598
- type: Injectable,
599
- args: [{
600
- providedIn: 'root'
601
- }]
602
- }], ctorParameters: () => [{ type: undefined, decorators: [{
603
- type: Inject,
604
- args: ['env']
605
- }] }, { type: i1.HttpClient }] });
606
-
607
- class ApiOpenItemsService {
608
- environments;
609
- http;
610
- constructor(environments, http) {
611
- this.environments = environments;
612
- this.http = http;
613
- }
614
- /**
615
- * Retrieves the API URL for open-items from the environments' configuration.
616
- *
617
- * @return {string} The API URL for open-items.
618
- */
619
- get url() {
620
- return this.environments.apiOpenItemsUrl;
621
- }
622
- /**
623
- * Retrieves a list of open-items based on the provided query parameters.
624
- *
625
- * @param {QueryParams} params - The parameters to use for querying open-items.
626
- * @return {Observable<OpenItemsOut>} An observable that emits the open-item's data.
627
- */
628
- getOpenItems(params) {
629
- return this.http.get(`${this.url}/open-items`, { params })
630
- .pipe(map(({ data }) => data));
631
- }
632
- /**
633
- * Processes a payment for an open item.
634
- *
635
- * @param {PaymentOpenItemIn} body - The payment details for the open item.
636
- * @return {Observable<PaymentOut>} An observable that emits the result of the payment processing.
637
- */
638
- postPayment(body) {
639
- return this.http.post(`${this.url}/payment`, body)
640
- .pipe(map(({ data }) => data));
641
- }
642
- /**
643
- * Processes a payment for other invoice.
644
- *
645
- * @param {OtherInvoiceIn} body - The payment details for the other invoice.
646
- * @return {Observable<OtherInvoiceOut>} An observable that emits the result of the payment processing.
647
- */
648
- postOtherInvoice(body) {
649
- return this.http.post(`${this.url}/other-invoices`, body)
650
- .pipe(map(({ data }) => data));
651
- }
652
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiOpenItemsService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
653
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiOpenItemsService, providedIn: 'root' });
435
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiInvoicesService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
436
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiInvoicesService, providedIn: 'root' });
654
437
  }
655
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiOpenItemsService, decorators: [{
438
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiInvoicesService, decorators: [{
656
439
  type: Injectable,
657
440
  args: [{
658
441
  providedIn: 'root'
@@ -675,7 +458,7 @@ class ApiReportsService {
675
458
  * @return {string} The URL of the reports API.
676
459
  */
677
460
  get url() {
678
- return this.environments.apiReportsUrl;
461
+ return this.environments.apiReportsUrl ?? '';
679
462
  }
680
463
  /**
681
464
  * Retrieves the list of collection payments
@@ -688,56 +471,10 @@ class ApiReportsService {
688
471
  params
689
472
  }).pipe(map(({ data }) => data));
690
473
  }
691
- /**
692
- * Fetches the list of shipments with pending payments.
693
- *
694
- * @param {ExistPendingPaymentsIn} params - The parameters to filter pending payment shipments.
695
- * @return {Observable<ShipmentsReportOut>} An observable emitting the shipments report data.
696
- */
697
- shipmentsPendingPayments(params) {
698
- return this.http.get(`${this.url}/shipments-report`, {
699
- params: {
700
- ...params,
701
- limit: 1,
702
- offset: 0,
703
- to_landing: true,
704
- shipment_status_code: 'PMPEN',
705
- },
706
- }).pipe(map(({ data }) => data));
707
- }
708
- /**
709
- * Fetches shipment reports that are pending invoices based on the specified parameters.
710
- * This method retrieves a filtered list of shipments with pending invoice statuses.
711
- *
712
- * @param {ExistPendingInvoicesIn} params - The parameters to filter the pending invoices, including
713
- * shipment status codes, and pagination options.
714
- * @return {Observable<ShipmentsReportOut>} An observable that emits the shipment report data based on the filter criteria.
715
- */
716
- shipmentsPendingInvoices(params) {
717
- return this.http.get(`${this.url}/shipments-report`, {
718
- params: {
719
- ...params,
720
- limit: 1,
721
- offset: 0,
722
- to_landing: true,
723
- 'shipment_status_code[in]': 'IPMPE,IMPEN,IPPEN',
724
- },
725
- }).pipe(map(({ data }) => data));
726
- }
727
- /**
728
- * Fetches shipment reports based on the provided query parameters.
729
- *
730
- * @param {QueryParams} params - The query parameters used to filter or define the shipment reports.
731
- * @return {Observable<ShipmentsReportOut>} An observable emitting the shipment report data.
732
- */
733
- getShipmentsReport(params) {
734
- return this.http.get(`${this.url}/shipments-report`, { params })
735
- .pipe(map(({ data }) => data));
736
- }
737
- 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 });
738
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiReportsService, providedIn: 'root' });
474
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiReportsService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
475
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiReportsService, providedIn: 'root' });
739
476
  }
740
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiReportsService, decorators: [{
477
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiReportsService, decorators: [{
741
478
  type: Injectable,
742
479
  args: [{
743
480
  providedIn: 'root'
@@ -762,7 +499,7 @@ class ApiSecurityService {
762
499
  * @return {string} The API security URL.
763
500
  */
764
501
  get url() {
765
- return this.environments.apiSecurityUrl;
502
+ return this.environments.apiSecurityUrl ?? '';
766
503
  }
767
504
  /**
768
505
  * Authenticates a user with the provided credentials and role.
@@ -771,9 +508,9 @@ class ApiSecurityService {
771
508
  * @param {string} param0.username - The username of the user.
772
509
  * @param {string} param0.password - The password of the user.
773
510
  * @param {string} param0.role - The role of the user.
774
- * @return {Observable<AuthLoginOut>} An observable emitting the login output object.
511
+ * @return {Observable<LoginOut>} An observable emitting the login output object.
775
512
  */
776
- postAuthLogin({ username, password, role, }) {
513
+ login({ username, password, role, }) {
777
514
  return this.http.post(`${this.url}/auth/login`, {
778
515
  system_name: 'CRA',
779
516
  username,
@@ -788,7 +525,7 @@ class ApiSecurityService {
788
525
  *
789
526
  * @return {Observable<{}>} An observable that emits the server's response to the logout request.
790
527
  */
791
- postAuthLogout() {
528
+ logout() {
792
529
  return this.http.post(`${this.url}/auth/logout`, null)
793
530
  .pipe(map(({ data }) => data), tap(() => this.cookie.delete(this.environments.authCookie, '/')));
794
531
  }
@@ -800,9 +537,9 @@ class ApiSecurityService {
800
537
  * @param {string} params.modelId - The ID of the model.
801
538
  * @param {string} [params.token] - Optional authorization token.
802
539
  *
803
- * @return {Observable<SessionOut>} An observable containing the created session details.
540
+ * @return {Observable<CreateSessionOut>} An observable containing the created session details.
804
541
  */
805
- postSession({ modelType, modelId, token, }) {
542
+ createSession({ modelType, modelId, token, }) {
806
543
  let headers = new HttpHeaders({});
807
544
  if (token) {
808
545
  headers = headers.set('Authorization', `Bearer ${token}`);
@@ -819,9 +556,9 @@ class ApiSecurityService {
819
556
  * Sends a GET request to the endpoint '/auth/me' to retrieve information
820
557
  * about the currently authenticated user.
821
558
  *
822
- * @return {Observable<AuthMeOut>} An observable that emits the authenticated user's data.
559
+ * @return {Observable<MeOut>} An observable that emits the authenticated user's data.
823
560
  */
824
- getAuthMe() {
561
+ me() {
825
562
  return this.http.get(`${this.url}/auth/me`)
826
563
  .pipe(map(({ data }) => data));
827
564
  }
@@ -831,7 +568,7 @@ class ApiSecurityService {
831
568
  * @param token The JWT token used for authorization.
832
569
  * @return An Observable that emits the user's details encapsulated in a MeOut object.
833
570
  */
834
- getOtherMe(token) {
571
+ otherMe(token) {
835
572
  return this.http.get(`${this.url}/auth/me`, {
836
573
  headers: {
837
574
  Authorization: `Bearer ${token}`
@@ -844,7 +581,7 @@ class ApiSecurityService {
844
581
  * @param {number} id - The unique identifier of the user to be fetched.
845
582
  * @return {Observable<GetUserOut>} An observable containing the user information.
846
583
  */
847
- getUser(id) {
584
+ user(id) {
848
585
  return this.http.get(`${this.url}/users/${id}`)
849
586
  .pipe(map(({ data }) => data));
850
587
  }
@@ -853,9 +590,9 @@ class ApiSecurityService {
853
590
  *
854
591
  * @param {Object} params - The input parameters for changing the language.
855
592
  * @param {string} params.languageId - The ID of the new language to be set.
856
- * @return {Observable<ApiSuccess<AuthMeOut>>} An observable that emits the result of the language change request.
593
+ * @return {Observable<ApiSuccess<MeOut>>} An observable that emits the result of the language change request.
857
594
  */
858
- putChangeLanguage({ languageId }) {
595
+ changeLanguage({ languageId }) {
859
596
  return this.http.put(`${this.url}/auth/me`, {
860
597
  language_id: languageId
861
598
  }).pipe(map(({ data }) => data));
@@ -864,7 +601,7 @@ class ApiSecurityService {
864
601
  * Retrieves a list of roles with their permissions.
865
602
  *
866
603
  * @param {QueryParams} params - The query parameters to filter the roles.
867
- * @returns {Observable<RoleIn[]>} An observable that emits an array of role permissions.
604
+ * @returns {Observable<RolePermissionsIn[]>} An observable that emits an array of role permissions.
868
605
  */
869
606
  getRoles(params) {
870
607
  return this.http.get(`${this.url}/roles`, {
@@ -882,23 +619,34 @@ class ApiSecurityService {
882
619
  params
883
620
  }).pipe(map(({ data }) => data));
884
621
  }
622
+ /**
623
+ * Retrieves the permissions for a module.
624
+ *
625
+ * @param {QueryParams} params - The query parameters to be sent with the request.
626
+ * @returns {Observable<ModulePermissionsOut>} An observable containing the module permissions.
627
+ */
628
+ getPermissions(params) {
629
+ return this.http.get(`${this.url}/modules`, {
630
+ params
631
+ }).pipe(map(({ data }) => data));
632
+ }
885
633
  /**
886
634
  * Retrieves roles by the specified ID.
887
635
  *
888
- * @param id - The ID of the role to retrieve.
636
+ * @param params - The ID of the role to retrieve.
889
637
  * @returns An Observable that emits the role data.
890
638
  */
891
- getRole(id) {
892
- return this.http.get(`${this.url}/roles/${id}`)
639
+ getRolesById(params) {
640
+ return this.http.get(`${this.url}/roles/${params}`)
893
641
  .pipe(map(({ data }) => data));
894
642
  }
895
643
  /**
896
644
  * Creates a new role with the specified permissions.
897
645
  *
898
- * @param {RoleIn} body - The permissions and details for the new role.
899
- * @returns {Observable<RoleOut>} An observable containing the created role's permissions.
646
+ * @param {RolePermissionsIn} body - The permissions and details for the new role.
647
+ * @returns {Observable<ModulePermissionsOut>} An observable containing the created role's permissions.
900
648
  */
901
- postRole(body) {
649
+ createRole(body) {
902
650
  return this.http.post(`${this.url}/roles`, body)
903
651
  .pipe(map(({ data }) => data));
904
652
  }
@@ -909,7 +657,7 @@ class ApiSecurityService {
909
657
  * @param body - The new permissions to assign to the role.
910
658
  * @returns An Observable that emits the updated module permissions.
911
659
  */
912
- putRole(id, body) {
660
+ updateRolePermissions(id, body) {
913
661
  return this.http.put(`${this.url}/roles/${id}`, body)
914
662
  .pipe(map(({ data }) => data));
915
663
  }
@@ -919,40 +667,14 @@ class ApiSecurityService {
919
667
  * @param {number} id - The unique identifier of the role whose permissions are to be deleted.
920
668
  * @returns {Observable<{}>} An observable that emits the result of the delete operation.
921
669
  */
922
- deleteRole(id) {
670
+ deleteRolePermissions(id) {
923
671
  return this.http.delete(`${this.url}/roles/${id}`)
924
672
  .pipe(map(({ data }) => data));
925
673
  }
926
- /**
927
- * Retrieves a list of modules and permissions
928
- *
929
- * @param queryParams - The query parameters to filter the modules.
930
- * @returns Observable<ModulesOut[]> - An observable that emits an array of modules and permissions.
931
- */
932
- getModules(queryParams) {
933
- return this.http.get(`${this.url}/modules`, {
934
- params: queryParams
935
- }).pipe(map(({ data }) => data));
936
- }
937
- /**
938
- * Retrieves a list of modules and permissions
939
- *
940
- * @param params.token - Custom token for authorization.
941
- * @param params.queryParams - The query parameters to filter the modules.
942
- * @returns Observable<ModulesOut[]> - An observable that emits an array of modules and permissions.
943
- */
944
- getModulesByToken(params) {
945
- return this.http.get(`${this.url}/modules`, {
946
- params: params.queryParams,
947
- headers: {
948
- Authorization: `Bearer ${params.token}`
949
- }
950
- }).pipe(map(({ data }) => data));
951
- }
952
- 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 });
953
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiSecurityService, providedIn: 'root' });
674
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiSecurityService, deps: [{ token: 'env' }, { token: i1$1.CookieService }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
675
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiSecurityService, providedIn: 'root' });
954
676
  }
955
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiSecurityService, decorators: [{
677
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiSecurityService, decorators: [{
956
678
  type: Injectable,
957
679
  args: [{
958
680
  providedIn: 'root'
@@ -975,7 +697,7 @@ class ApiShipmentsService {
975
697
  * @return {string} The URL of the shipments API.
976
698
  */
977
699
  get url() {
978
- return this.environments.apiShipmentUrl;
700
+ return this.environments.apiShipmentUrl ?? '';
979
701
  }
980
702
  /**
981
703
  * Retrieves the parameter values based on the provided parameter names.
@@ -984,24 +706,14 @@ class ApiShipmentsService {
984
706
  * @return {Observable<ValidateAccountIn>} An observable that emits the fetched parameter values
985
707
  * @param body
986
708
  */
987
- postValidateAccount(body) {
709
+ validateAccount(body) {
988
710
  return this.http.post(`${this.url}/accounts`, body)
989
711
  .pipe(map(({ data }) => data));
990
712
  }
991
- /**
992
- * Sends a POST request to the shipments manifest endpoint with the provided body.
993
- *
994
- * @param body - The request payload of type `ManifestMultipleIn`.
995
- * @returns An observable that emits the response data of type `ManifestMultipleOut`.
996
- */
997
- postManifestMultiple(body) {
998
- return this.http.post(`${this.url}/shipments/manifest`, body)
999
- .pipe(map(({ data }) => data));
1000
- }
1001
- 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 });
1002
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiShipmentsService, providedIn: 'root' });
713
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiShipmentsService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
714
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiShipmentsService, providedIn: 'root' });
1003
715
  }
1004
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiShipmentsService, decorators: [{
716
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiShipmentsService, decorators: [{
1005
717
  type: Injectable,
1006
718
  args: [{
1007
719
  providedIn: 'root'
@@ -1011,117 +723,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
1011
723
  args: ['env']
1012
724
  }] }, { type: i1.HttpClient }] });
1013
725
 
1014
- class WebSocketsService {
1015
- environments;
1016
- pusher;
1017
- constructor(environments) {
1018
- this.environments = environments;
1019
- this.pusher = null;
1020
- this.connect()
1021
- .then((pusher) => {
1022
- if (!pusher)
1023
- return;
1024
- this.pusher = pusher;
1025
- });
1026
- }
1027
- /**
1028
- * Publishes an event to the specified channel with the given data.
1029
- *
1030
- * @param {Channel} channel - The channel instance where the event will be published.
1031
- * @param {string} eventName - The name of the event to be published.
1032
- * @param {T} data - The payload data to be sent with the event.
1033
- * @return {Promise<boolean>} A promise that resolves to a boolean indicating
1034
- * whether the event was successfully triggered on the channel.
1035
- */
1036
- async pub(channel, eventName, data) {
1037
- return channel.trigger(`client-${eventName}`, data);
1038
- }
1039
- /**
1040
- * Subscribes to a specified channel, retrying multiple times upon failure.
1041
- *
1042
- * @param {string} channelName - The name of the channel to be subscribed to.
1043
- * @return {Promise<Channel>} A promise that resolves to the subscribed channel object if successful.
1044
- * @throws {Error} If the subscription fails after the maximum number of retry attempts.
1045
- */
1046
- async channelSub(channelName) {
1047
- const attempts = 3;
1048
- for (let attempt = 0; attempt <= attempts; attempt++) {
1049
- const channel = this.pusher?.channel(channelName);
1050
- if (channel?.subscribed) {
1051
- return channel;
1052
- }
1053
- this.pusher?.subscribe(channelName);
1054
- if (attempt < attempts) {
1055
- await this.wait();
1056
- }
1057
- }
1058
- throw new Error(`Failed to subscribe to channel "${channelName}" after ${attempts} attempts.`);
1059
- }
1060
- /**
1061
- * Binds an event listener to a specified event on a given channel using Pusher or a Channel object,
1062
- * and returns an Observable that emits event data of type T.
1063
- *
1064
- * @param {Channel|string} channel - The channel to bind the event to. It can be a Channel object or a string representing the channel name.
1065
- * @param {string} event - The name of the event to bind to the channel.
1066
- * @return {Observable<T>} An Observable that emits data of type T when the specified event is triggered.
1067
- */
1068
- eventBind(channel, event) {
1069
- return new Observable((subscriber) => {
1070
- if (channel?.name) {
1071
- channel.bind(event, (data) => subscriber.next(data));
1072
- }
1073
- else {
1074
- this.pusher?.subscribe(channel)
1075
- .bind(event, (data) => subscriber.next(data));
1076
- }
1077
- });
1078
- }
1079
- /**
1080
- * Unbinds an event from the specified channel and returns an observable
1081
- * that emits data when the event callback is triggered.
1082
- *
1083
- * @param {Channel} channel - The channel object from which the event should be unbound.
1084
- * @param {string} event - The name of the event to unbind.
1085
- * @return {Observable<T>} An observable that emits data from the unbound event callback.
1086
- */
1087
- eventUnbind(channel, event) {
1088
- return new Observable((subscriber) => channel.unbind(event, (data) => subscriber.next(data)));
1089
- }
1090
- connect() {
1091
- return new Promise((resolve) => {
1092
- const { sockets } = this.environments;
1093
- if (!sockets)
1094
- return resolve(false);
1095
- const pusher = new Pusher__default(sockets.app_key, {
1096
- wsHost: sockets.url,
1097
- wsPort: sockets.port,
1098
- enabledTransports: ['wss', 'ws'],
1099
- forceTLS: false,
1100
- enableStats: false,
1101
- });
1102
- if (sockets.debug) {
1103
- Pusher__default.logToConsole = true;
1104
- }
1105
- return resolve(pusher);
1106
- });
1107
- }
1108
- async wait() {
1109
- const waitTime = 3 * 1000;
1110
- return new Promise((resolve) => setTimeout(resolve, waitTime));
1111
- }
1112
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: WebSocketsService, deps: [{ token: 'env' }], target: i0.ɵɵFactoryTarget.Injectable });
1113
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: WebSocketsService, providedIn: 'root' });
1114
- }
1115
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: WebSocketsService, decorators: [{
1116
- type: Injectable,
1117
- args: [{
1118
- providedIn: 'root',
1119
- }]
1120
- }], ctorParameters: () => [{ type: undefined, decorators: [{
1121
- type: Inject,
1122
- args: ['env']
1123
- }] }] });
1124
-
1125
726
  class CryptoService {
1126
727
  environments;
1127
728
  constructor(environments) {
@@ -1200,10 +801,10 @@ class CryptoService {
1200
801
  }
1201
802
  return bytes.buffer;
1202
803
  }
1203
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CryptoService, deps: [{ token: 'env' }], target: i0.ɵɵFactoryTarget.Injectable });
1204
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CryptoService, providedIn: 'root' });
804
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: CryptoService, deps: [{ token: 'env' }], target: i0.ɵɵFactoryTarget.Injectable });
805
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: CryptoService, providedIn: 'root' });
1205
806
  }
1206
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CryptoService, decorators: [{
807
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: CryptoService, decorators: [{
1207
808
  type: Injectable,
1208
809
  args: [{
1209
810
  providedIn: 'root'
@@ -1213,189 +814,86 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
1213
814
  args: ['env']
1214
815
  }] }] });
1215
816
 
1216
- class ApiHeadersInterceptor {
1217
- /**
1218
- * Intercepts HTTP requests and modifies request headers to include caching, content type,
1219
- * accept language, and other HTTP-specific configurations before forwarding the request onward.
1220
- *
1221
- * @param {HttpRequest<unknown>} request - The HTTP request instance to be intercepted and modified.
1222
- * @param {HttpHandler} next - The next handler instance in the HTTP pipeline which processes
1223
- * the modified request and forwards it.
1224
- * @return {Observable<HttpEvent<unknown>>} An observable of the processed HTTP event.
1225
- */
1226
- intercept(request, next) {
1227
- let headers = new HttpHeaders({
1228
- 'cache-control': 'max-age=0, no-cache, no-store, must-revalidate',
1229
- expires: '0',
1230
- pragma: 'no-cache'
1231
- });
1232
- if (!request.headers.has('Content-Type')) {
1233
- headers = headers.set('Content-Type', 'application/json');
1234
- }
1235
- if (!request.headers.has('Accept')) {
1236
- headers = headers.set('Accept', 'application/json');
1237
- }
1238
- if (!request.headers.has('Accept-Language')) {
1239
- headers = headers.set('Accept-Language', localStorage.getItem('lang') ?? 'en');
1240
- }
1241
- request = request.clone({ headers });
1242
- return next.handle(request);
1243
- }
1244
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiHeadersInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1245
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiHeadersInterceptor });
1246
- }
1247
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiHeadersInterceptor, decorators: [{
1248
- type: Injectable
1249
- }] });
1250
-
1251
- class ApiTokenInterceptor {
1252
- environments;
1253
- cookie;
1254
- constructor(environments, cookie) {
1255
- this.environments = environments;
1256
- this.cookie = cookie;
1257
- }
1258
- /**
1259
- * Intercepts and modifies the outgoing HTTP request to include an authorization token
1260
- * from cookies if the request does not already have an Authorization or AppKey header.
1261
- *
1262
- * @param {HttpRequest<unknown>} request - The outgoing HTTP request to be intercepted.
1263
- * @param {HttpHandler} next - The next handler in the HTTP request processing chain.
1264
- * @return {Observable<HttpEvent<unknown>>} An observable of the HTTP event, modified or unmodified.
1265
- */
1266
- intercept(request, next) {
1267
- if (request.headers.has('Authorization') || request.headers.has('AppKey')) {
1268
- return next.handle(request);
1269
- }
1270
- const token = this.cookie.get(this.environments.authCookie);
1271
- if (!token)
1272
- return next.handle(request);
1273
- request = request.clone({
1274
- setHeaders: {
1275
- Authorization: `Bearer ${token}`
1276
- }
1277
- });
1278
- return next.handle(request);
817
+ /**
818
+ * Intercepts an outgoing HTTP request and modifies its headers to include default values
819
+ * for Cache-Control, Expires, Pragma, Content-Type, Accept, and Accept-Language if they
820
+ * are not already present.
821
+ *
822
+ * @param {HttpRequest<unknown>} req - The outgoing HTTP request to be intercepted and modified.
823
+ * @param {HttpHandlerFn} next - The next handler in the chain to pass the modified request to.
824
+ * @return {Observable<HttpEvent<unknown>>} An observable of the HTTP event resulting from the processed request.
825
+ */
826
+ function apiHeadersInterceptor(req, next) {
827
+ let { headers } = req;
828
+ if (!headers.has('Content-Type')) {
829
+ headers = headers.set('Content-Type', 'application/json');
1279
830
  }
1280
- 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 });
1281
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiTokenInterceptor });
1282
- }
1283
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiTokenInterceptor, decorators: [{
1284
- type: Injectable
1285
- }], ctorParameters: () => [{ type: undefined, decorators: [{
1286
- type: Inject,
1287
- args: ['env']
1288
- }] }, { type: i1$1.CookieService }] });
1289
-
1290
- const DEFAULT_TTL = 10000; // ttl in ms
1291
- class HttpCachingInterceptor {
1292
- envs;
1293
- cache = new Map();
1294
- constructor(envs) {
1295
- this.envs = envs;
831
+ if (!headers.has('Accept')) {
832
+ headers = headers.set('Accept', 'application/json');
1296
833
  }
1297
- /**
1298
- * Intercepts HTTP requests to add caching functionality for GET requests.
1299
- * Non-GET requests are passed through without caching.
1300
- *
1301
- * @param {HttpRequest<any>} req - The HTTP request being intercepted.
1302
- * @param {HttpHandler} next - The next handler in the HTTP pipeline to execute the request.
1303
- * @return {Observable<HttpEvent<any>>} - An observable containing the HTTP response event, either from cache or the backend service.
1304
- */
1305
- intercept(req, next) {
1306
- if (req.method !== 'GET') {
1307
- return next.handle(req);
1308
- }
1309
- const cached = this.cache.get(req.urlWithParams);
1310
- if (cached) {
1311
- const isExpired = Date.now() > cached.ttl;
1312
- if (!isExpired) {
1313
- return of(cached.res);
1314
- }
1315
- this.cache.delete(req.urlWithParams); // If expired, remove the entry from cache
1316
- }
1317
- return next.handle(req).pipe(tap$1((res) => {
1318
- if (!(res instanceof HttpResponse)) {
1319
- return;
1320
- }
1321
- const ttl = Date.now() + (this.envs.cacheTtl ?? DEFAULT_TTL);
1322
- this.cache.set(req.urlWithParams, { res, ttl });
1323
- }));
834
+ if (!headers.has('Accept-Language')) {
835
+ headers = headers.set('Accept-Language', localStorage.getItem('lang') ?? 'en');
1324
836
  }
1325
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: HttpCachingInterceptor, deps: [{ token: 'env' }], target: i0.ɵɵFactoryTarget.Injectable });
1326
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: HttpCachingInterceptor });
837
+ req = req.clone({ headers });
838
+ return next(req);
1327
839
  }
1328
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: HttpCachingInterceptor, decorators: [{
1329
- type: Injectable
1330
- }], ctorParameters: () => [{ type: undefined, decorators: [{
1331
- type: Inject,
1332
- args: ['env']
1333
- }] }] });
1334
840
 
1335
841
  /**
1336
- * Convert an object of key-value pairs into a URL query string.
1337
- *
1338
- * @param {Object} params - The key-value pairs to converted into a query string.
842
+ * An HTTP interceptor to append an Authorization header with a Bearer token
843
+ * to outgoing HTTP requests if certain conditions are met.
1339
844
  *
1340
- * @return {string} - The generated query string.
845
+ * @param {HttpRequest<unknown>} req - The outgoing HTTP request object which may be modified.
846
+ * @param {HttpHandlerFn} next - The next handler in the HTTP request pipeline.
847
+ * @return {Observable<HttpEvent<unknown>>} An observable of the HTTP event stream resulting from the request.
1341
848
  */
1342
- const queryString = (params) => {
1343
- const queryElements = [];
1344
- Object.entries(params).forEach(([key, value]) => {
1345
- if (Array.isArray(value)) {
1346
- const arrayQuery = value
1347
- .map((item) => `${encodeURIComponent(key)}=${encodeURIComponent(item)}`)
1348
- .join('&');
1349
- queryElements.push(arrayQuery);
1350
- }
1351
- else {
1352
- const encodedQuery = `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
1353
- queryElements.push(encodedQuery);
849
+ function apiTokenInterceptor(req, next) {
850
+ const { authCookie } = inject(ENVIRONMENT_TOKEN);
851
+ const cookie = inject(CookieService);
852
+ if (req.headers.has('Authorization') || req.headers.has('AppKey')) {
853
+ return next(req);
854
+ }
855
+ const token = cookie.get(authCookie);
856
+ if (!token)
857
+ return next(req);
858
+ req = req.clone({
859
+ setHeaders: {
860
+ Authorization: `Bearer ${token}`
1354
861
  }
1355
862
  });
1356
- const queryString = queryElements.join('&');
1357
- return queryString.length ? `?${queryString}` : '';
1358
- };
1359
- /**
1360
- * Creates an instance of HttpParams using the provided params object.
1361
- *
1362
- * @param {Object} params - The object containing the params to the HttpParams constructor.
1363
- *
1364
- * @returns {HttpParams} - An instance of HttpParams created from the params object.
1365
- */
1366
- const httpParams = (params) => new HttpParams({
1367
- fromObject: params
1368
- });
1369
- /**
1370
- * Returns the headers for generating PDF files.
1371
- *
1372
- * @param {string} format - The format of the headers, 'object' or 'http_header'.
1373
- *
1374
- * @returns {HttpHeaders | { [header: string]: string | string[] }} - The headers for generating PDF files.
1375
- */
1376
- const pdfHeaders = (format = 'object') => {
1377
- const headers = {
1378
- Accept: 'application/pdf'
1379
- };
1380
- return format === 'object'
1381
- ? headers
1382
- : new HttpHeaders(headers);
1383
- };
863
+ return next(req);
864
+ }
865
+
866
+ const DEFAULT_TTL = 10000; // ttl in ms
867
+ const cache = new Map();
1384
868
  /**
1385
- * Returns the headers for generating XML files.
869
+ * Interceptor function to handle HTTP caching for GET requests. It retrieves cached responses
870
+ * if available and valid; otherwise, it processes the request and caches the response for future use.
1386
871
  *
1387
- * @param {string} format - The format of the headers, 'object' or 'http_header'.
1388
- *
1389
- * @returns {HttpHeaders | { [header: string]: string | string[] }} - The headers for generating XML files.
872
+ * @param {HttpRequest<any>} req - The HTTP request object being intercepted.
873
+ * @param {HttpHandlerFn} next - The next HTTP handler function in the chain to process the request.
874
+ * @return {Observable<HttpEvent<any>>} An observable that emits the HTTP event, either from cache
875
+ * or by invoking the next handler.
1390
876
  */
1391
- const xmlHeaders = (format = 'object') => {
1392
- const headers = {
1393
- Accept: 'application/xml',
1394
- };
1395
- return format === 'object'
1396
- ? headers
1397
- : new HttpHeaders(headers);
1398
- };
877
+ function httpCachingInterceptor(req, next) {
878
+ const { cacheTtl } = inject(ENVIRONMENT_TOKEN);
879
+ if (req.method !== 'GET')
880
+ return next(req);
881
+ const cached = cache.get(req.urlWithParams);
882
+ if (cached) {
883
+ const isExpired = Date.now() > cached.ttl;
884
+ if (!isExpired) {
885
+ return of(cached.res);
886
+ }
887
+ cache.delete(req.urlWithParams); // If expired, remove the entry from cache
888
+ }
889
+ return next(req).pipe(tap$1((res) => {
890
+ if (!(res instanceof HttpResponse)) {
891
+ return;
892
+ }
893
+ const ttl = Date.now() + (cacheTtl ?? DEFAULT_TTL);
894
+ cache.set(req.urlWithParams, { res, ttl });
895
+ }));
896
+ }
1399
897
 
1400
898
  /*
1401
899
  * Public API Surface of ngx-services
@@ -1405,5 +903,5 @@ const xmlHeaders = (format = 'object') => {
1405
903
  * Generated bundle index. Do not edit.
1406
904
  */
1407
905
 
1408
- export { ApiBillingDOService, ApiBillingMxService, ApiCompaniesService, ApiExternalPickupsService, ApiHeadersInterceptor, ApiInvoicesService, ApiOpenItemsService, ApiReportsService, ApiSecurityService, ApiShipmentsService, ApiTokenInterceptor, CryptoService, HttpCachingInterceptor, NgxServicesModule, WebSocketsService, httpParams, pdfHeaders, queryString, xmlHeaders };
906
+ export { ApiCompaniesService, ApiInvoicesService, ApiReportsService, ApiSecurityService, ApiShipmentsService, CryptoService, ENVIRONMENT_TOKEN, NgxServicesModule, apiHeadersInterceptor, apiTokenInterceptor, httpCachingInterceptor, httpParams, pdfHeaders, queryString, xmlHeaders };
1409
907
  //# sourceMappingURL=experteam-mx-ngx-services.mjs.map