@experteam-mx/ngx-services 18.4.1 → 18.4.3

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 (55) hide show
  1. package/esm2022/lib/apis/api-billing-do.service.mjs +41 -0
  2. package/esm2022/lib/apis/api-billing-mx.service.mjs +62 -0
  3. package/esm2022/lib/apis/api-companies.service.mjs +20 -21
  4. package/esm2022/lib/apis/api-external-pickups.service.mjs +74 -0
  5. package/esm2022/lib/apis/api-invoices.service.mjs +78 -8
  6. package/esm2022/lib/apis/api-open-items.service.mjs +62 -0
  7. package/esm2022/lib/apis/api-reports.service.mjs +47 -1
  8. package/esm2022/lib/apis/api-security.service.mjs +88 -49
  9. package/esm2022/lib/apis/api-shipments.service.mjs +12 -2
  10. package/esm2022/lib/apis/models/api-billing.interfaces.mjs +2 -0
  11. package/esm2022/lib/apis/models/api-billing.types.mjs +2 -0
  12. package/esm2022/lib/apis/models/api-catalog.interfaces.mjs +1 -1
  13. package/esm2022/lib/apis/models/api-companies.types.mjs +1 -1
  14. package/esm2022/lib/apis/models/api-external-pickups.types.mjs +2 -0
  15. package/esm2022/lib/apis/models/api-invoices.interfaces.mjs +1 -1
  16. package/esm2022/lib/apis/models/api-invoices.types.mjs +1 -1
  17. package/esm2022/lib/apis/models/api-open-items.interfaces.mjs +2 -0
  18. package/esm2022/lib/apis/models/api-open-items.types.mjs +2 -0
  19. package/esm2022/lib/apis/models/api-reports.interfaces.mjs +1 -1
  20. package/esm2022/lib/apis/models/api-reports.types.mjs +1 -1
  21. package/esm2022/lib/apis/models/api-security.interfaces.mjs +1 -1
  22. package/esm2022/lib/apis/models/api-security.types.mjs +1 -1
  23. package/esm2022/lib/apis/models/api-shipments.types.mjs +1 -1
  24. package/esm2022/lib/ngx-services.models.mjs +1 -1
  25. package/esm2022/lib/websockets/web-sockets.service.mjs +115 -0
  26. package/esm2022/public-api.mjs +11 -1
  27. package/fesm2022/experteam-mx-ngx-services.mjs +643 -143
  28. package/fesm2022/experteam-mx-ngx-services.mjs.map +1 -1
  29. package/lib/apis/api-billing-do.service.d.ts +24 -0
  30. package/lib/apis/api-billing-mx.service.d.ts +39 -0
  31. package/lib/apis/api-companies.service.d.ts +9 -9
  32. package/lib/apis/api-external-pickups.service.d.ts +46 -0
  33. package/lib/apis/api-invoices.service.d.ts +59 -9
  34. package/lib/apis/api-open-items.service.d.ts +41 -0
  35. package/lib/apis/api-reports.service.d.ts +24 -1
  36. package/lib/apis/api-security.service.d.ts +64 -32
  37. package/lib/apis/api-shipments.service.d.ts +10 -3
  38. package/lib/apis/models/api-billing.interfaces.d.ts +41 -0
  39. package/lib/apis/models/api-billing.types.d.ts +17 -0
  40. package/lib/apis/models/api-catalog.interfaces.d.ts +6 -0
  41. package/lib/apis/models/api-companies.types.d.ts +7 -13
  42. package/lib/apis/models/api-external-pickups.types.d.ts +31 -0
  43. package/lib/apis/models/api-invoices.interfaces.d.ts +35 -1
  44. package/lib/apis/models/api-invoices.types.d.ts +57 -5
  45. package/lib/apis/models/api-open-items.interfaces.d.ts +32 -0
  46. package/lib/apis/models/api-open-items.types.d.ts +58 -0
  47. package/lib/apis/models/api-reports.interfaces.d.ts +149 -0
  48. package/lib/apis/models/api-reports.types.d.ts +13 -4
  49. package/lib/apis/models/api-security.interfaces.d.ts +2 -6
  50. package/lib/apis/models/api-security.types.d.ts +41 -11
  51. package/lib/apis/models/api-shipments.types.d.ts +41 -0
  52. package/lib/ngx-services.models.d.ts +11 -0
  53. package/lib/websockets/web-sockets.service.d.ts +49 -0
  54. package/package.json +11 -2
  55. package/public-api.d.ts +9 -0
@@ -1,11 +1,12 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, NgModule, Injectable, Inject, inject } from '@angular/core';
3
3
  import * as i1 from '@angular/common/http';
4
- import { provideHttpClient, HttpParams, HttpHeaders, HttpResponse } from '@angular/common/http';
5
- import { map, mergeMap, forkJoin, tap, of } from 'rxjs';
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';
6
7
  import * as i1$1 from 'ngx-cookie-service';
7
8
  import { CookieService } from 'ngx-cookie-service';
8
- import { tap as tap$1 } from 'rxjs/operators';
9
+ import Pusher from 'pusher-js';
9
10
 
10
11
  /**
11
12
  * Injection token used to inject environment configurations.
@@ -47,70 +48,100 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
47
48
  }]
48
49
  }] });
49
50
 
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
- };
51
+ class ApiBillingDOService {
52
+ environments;
53
+ http;
54
+ constructor(environments, http) {
55
+ this.environments = environments;
56
+ this.http = http;
57
+ }
58
+ /**
59
+ * Retrieves the URL for the shipments API from the environment configurations.
60
+ *
61
+ * @return {string} The URL of the shipments API.
62
+ */
63
+ get url() {
64
+ return this.environments.apiBillingDO ?? '';
65
+ }
66
+ /**
67
+ * Retrieves a list of income types
68
+ *
69
+ * @return {Observable<ApiSuccess<IncomeTypesOut>>} An observable that emits the income types data.
70
+ */
71
+ getIncomeTypes() {
72
+ return this.http.get(`${this.url}/income-types`)
73
+ .pipe(map(({ data }) => data));
74
+ }
75
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiBillingDOService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
76
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiBillingDOService, providedIn: 'root' });
77
+ }
78
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiBillingDOService, decorators: [{
79
+ type: Injectable,
80
+ args: [{
81
+ providedIn: 'root'
82
+ }]
83
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
84
+ type: Inject,
85
+ args: ['env']
86
+ }] }, { type: i1.HttpClient }] });
87
+
88
+ class ApiBillingMxService {
89
+ environments;
90
+ http;
91
+ constructor(environments, http) {
92
+ this.environments = environments;
93
+ this.http = http;
94
+ }
95
+ /**
96
+ * Retrieves the URL for the shipments API from the environment configurations.
97
+ *
98
+ * @return {string} The URL of the shipments API.
99
+ */
100
+ get url() {
101
+ return this.environments.apiBillingMX ?? '';
102
+ }
103
+ /**
104
+ * Fetches the tax regimen data from the server.
105
+ *
106
+ * @return {Observable<FiscalRegimensOut>} An observable that emits the fiscal regimen data.
107
+ */
108
+ getFiscalRegimens() {
109
+ return this.http.get(`${this.url}/fiscal-regimens`)
110
+ .pipe(map(({ data }) => data));
111
+ }
112
+ /**
113
+ * Fetches a paginated list of CFDIs (Comprobante Fiscal Digital por Internet) based on the provided fiscal regimen.
114
+ *
115
+ * @param {number} fiscalRegimen - The fiscal regimen identifier to filter the CFDIs.
116
+ * @return {Observable<FiscalRegimensAcceptedOut>} An observable containing the paginated list of CFDIs.
117
+ */
118
+ getFiscalRegimensAccepted(fiscalRegimen) {
119
+ const params = { 'fiscal-regimen': fiscalRegimen };
120
+ return this.http.get(`${this.url}/cfdi-uses/fiscal-regimen-accepted/list`, { params })
121
+ .pipe(map(({ data }) => data));
122
+ }
123
+ /**
124
+ * Fetches and validates postal code data from the server.
125
+ *
126
+ * @param {QueryParams} params - Query parameters used to filter the postal code data.
127
+ * @return {Observable<PostalCodesOut>} - An observable emitting the validated postal code data.
128
+ */
129
+ getPostalCodes(params) {
130
+ return this.http.get(`${this.url}/postal-codes`, { params })
131
+ .pipe(map(({ data }) => data));
132
+ }
133
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiBillingMxService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
134
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiBillingMxService, providedIn: 'root' });
135
+ }
136
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiBillingMxService, decorators: [{
137
+ type: Injectable,
138
+ args: [{
139
+ providedIn: 'root'
140
+ }]
141
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
142
+ type: Inject,
143
+ args: ['env']
144
+ }] }, { type: i1.HttpClient }] });
114
145
 
115
146
  class ApiCompaniesService {
116
147
  environments;
@@ -135,7 +166,7 @@ class ApiCompaniesService {
135
166
  */
136
167
  getInstallations(params) {
137
168
  return this.http.get(`${this.url}/installations`, {
138
- params: httpParams(params),
169
+ params,
139
170
  }).pipe(map(({ data }) => data));
140
171
  }
141
172
  /**
@@ -156,7 +187,7 @@ class ApiCompaniesService {
156
187
  */
157
188
  getLocations(params) {
158
189
  return this.http.get(`${this.url}/locations`, {
159
- params: httpParams(params),
190
+ params,
160
191
  }).pipe(map(({ data }) => data));
161
192
  }
162
193
  /**
@@ -173,11 +204,11 @@ class ApiCompaniesService {
173
204
  * Retrieves a list of active supply entities.
174
205
  *
175
206
  * @param {QueryParams} params - The query parameters to filter supply entities.
176
- * @return {Observable<SupplyEntitiesOut>} Observable emitting supply entities data.
207
+ * @return {Observable<SupplyEntitiesActivesOut>} Observable emitting supply entities data.
177
208
  */
178
- getSupplyEntitiesActive(params) {
209
+ getSupplyEntitiesActives(params) {
179
210
  return this.http.get(`${this.url}/supply-entities/actives`, {
180
- params: httpParams(params),
211
+ params,
181
212
  }).pipe(map(({ data }) => data));
182
213
  }
183
214
  /**
@@ -188,7 +219,7 @@ class ApiCompaniesService {
188
219
  */
189
220
  getEmployees(params) {
190
221
  return this.http.get(`${this.url}/employees`, {
191
- params: httpParams(params),
222
+ params,
192
223
  }).pipe(map(({ data }) => data));
193
224
  }
194
225
  /**
@@ -209,7 +240,7 @@ class ApiCompaniesService {
209
240
  */
210
241
  getLocationEmployees(params) {
211
242
  return this.http.get(`${this.url}/location-employees`, {
212
- params: httpParams(params),
243
+ params,
213
244
  }).pipe(map(({ data }) => data));
214
245
  }
215
246
  /**
@@ -220,7 +251,7 @@ class ApiCompaniesService {
220
251
  */
221
252
  getCompanyCountries(params) {
222
253
  return this.http.get(`${this.url}/company-countries`, {
223
- params: httpParams(params),
254
+ params,
224
255
  }).pipe(map(({ data }) => data));
225
256
  }
226
257
  /**
@@ -265,11 +296,11 @@ class ApiCompaniesService {
265
296
  * Fetches exchange data based on the provided query parameters.
266
297
  *
267
298
  * @param {QueryParams} params - The query parameters for retrieving exchange data.
268
- * @return {Observable<CountryExchangesOut>} An observable containing the exchange data.
299
+ * @return {Observable<ExchangesOut>} An observable containing the exchange data.
269
300
  */
270
301
  getExchanges(params) {
271
302
  return this.http.get(`${this.url}/exchanges`, {
272
- params: httpParams(params),
303
+ params,
273
304
  }).pipe(map(({ data }) => data));
274
305
  }
275
306
  /**
@@ -281,7 +312,7 @@ class ApiCompaniesService {
281
312
  */
282
313
  getCurrentExchanges(params) {
283
314
  return this.http.get(`${this.url}/exchanges/current`, {
284
- params: httpParams(params),
315
+ params,
285
316
  }).pipe(map(({ data }) => data));
286
317
  }
287
318
  /**
@@ -292,18 +323,18 @@ class ApiCompaniesService {
292
323
  */
293
324
  getCompanyCountryTaxes(params) {
294
325
  return this.http.get(`${this.url}/company-country-taxes`, {
295
- params: httpParams(params),
326
+ params,
296
327
  }).pipe(map(({ data }) => data));
297
328
  }
298
329
  /**
299
330
  * Retrieves the list of active account entities based on the provided query parameters.
300
331
  *
301
332
  * @param {QueryParams} params - The parameters to filter and query active account entities.
302
- * @return {Observable<AccountEntitiesOut>} An observable that emits the list of active account entities.
333
+ * @return {Observable<AccountEntitiesActivesOut>} An observable that emits the list of active account entities.
303
334
  */
304
- getActiveAccountEntities(params) {
335
+ getAccountEntitiesActives(params) {
305
336
  return this.http.get(`${this.url}/account-entities/actives`, {
306
- params: httpParams(params),
337
+ params,
307
338
  }).pipe(map(({ data }) => data));
308
339
  }
309
340
  /**
@@ -311,9 +342,9 @@ class ApiCompaniesService {
311
342
  *
312
343
  * @param {Object} params - An object containing the required parameters.
313
344
  * @param {string[]} params.paramNames - An array of parameter names for which the values need to be fetched.
314
- * @return {Observable<ParametersOut>} An observable that emits the fetched parameter values.
345
+ * @return {Observable<ParametersValuesOut>} An observable that emits the fetched parameter values.
315
346
  */
316
- getParameters({ paramNames, }) {
347
+ getParametersValues({ paramNames, }) {
317
348
  const parameters = paramNames.map((p) => ({ name: p }));
318
349
  return this.http.post(`${this.url}/parameters-values`, {
319
350
  parameters
@@ -338,7 +369,7 @@ class ApiCompaniesService {
338
369
  */
339
370
  getCountryReferences(params) {
340
371
  return this.http.get(`${this.url}/country-references`, {
341
- params: httpParams(params),
372
+ params,
342
373
  }).pipe(map(({ data }) => data));
343
374
  }
344
375
  /**
@@ -359,7 +390,7 @@ class ApiCompaniesService {
359
390
  */
360
391
  getWorkflows(params) {
361
392
  return this.http.get(`${this.url}/workflows`, {
362
- params: httpParams(params),
393
+ params,
363
394
  }).pipe(map(({ data }) => data));
364
395
  }
365
396
  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 });
@@ -375,6 +406,76 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
375
406
  args: ['env']
376
407
  }] }, { type: i1.HttpClient }] });
377
408
 
409
+ class ApiExternalPickupsService {
410
+ httpClient;
411
+ environment;
412
+ appKey;
413
+ constructor(httpClient, environment) {
414
+ this.httpClient = httpClient;
415
+ this.environment = environment;
416
+ this.appKey = environment.apiExternalOperationsKey ?? '';
417
+ }
418
+ /**
419
+ * Getter method to retrieve the API's external operations URL.
420
+ * Fetches the URL from the `apiExternalOperationsUrl` property of the environment object.
421
+ * Defaults to an empty string if the property is undefined or null.
422
+ *
423
+ * @return {string} The external operations URL or an empty string if unavailable.
424
+ */
425
+ get url() {
426
+ return this.environment.apiExternalOperationsUrl ?? '';
427
+ }
428
+ /**
429
+ * Generates a delivery confirmation by sending the provided payload to the API.
430
+ *
431
+ * @param {DeliveryConfirmationGenerateIn} payload - The input payload required to generate the delivery confirmation.
432
+ * @return {Observable<DeliveryConfirmationGenerateOut>} An observable that emits the generated delivery confirmation data.
433
+ */
434
+ postDeliveryConfirmationGenerate(payload) {
435
+ return this.httpClient.post(`${this.url}/delivery-confirmation/generate`, payload, {
436
+ headers: { appkey: this.appKey }
437
+ }).pipe(map$1(({ data }) => data));
438
+ }
439
+ /**
440
+ * Confirms the completion of a delivery operation by making a PATCH request.
441
+ *
442
+ * @param {Object} input - The input parameters for the method.
443
+ * @param {string} input.operationId - The unique identifier of the delivery operation to be confirmed.
444
+ * @param {string} input.keyOTP - The one-time password (OTP) key associated with the delivery confirmation.
445
+ * @return {Observable<Object>} - An observable containing the response data from the API.
446
+ */
447
+ patchDeliveryConfirmationComplete({ keyOTP, operationId, }) {
448
+ return this.httpClient.patch(`${this.url}/delivery-confirmation/completed/${keyOTP}`, null, {
449
+ headers: { appkey: this.appKey },
450
+ params: { operation_id: operationId }
451
+ }).pipe(map$1(({ data }) => data));
452
+ }
453
+ /**
454
+ * Cancels a delivery confirmation by sending an OTP and additional data to the server.
455
+ *
456
+ * @param {Object} param0 - The parameter object containing the required properties.
457
+ * @param {string} param0.otp - The one-time password to authenticate the cancellation request.
458
+ * @param {Object} param0.body - Additional body data required for cancellation.
459
+ * @return {Observable<Object>} An observable that emits the server's response when the cancellation is processed.
460
+ */
461
+ putDeliveryConfirmation({ otp, ...body }) {
462
+ return this.httpClient.put(`${this.url}/delivery-confirmation/confirmation/${otp}`, body, {
463
+ headers: { appkey: this.appKey },
464
+ }).pipe(map$1(({ data }) => data));
465
+ }
466
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiExternalPickupsService, deps: [{ token: i1.HttpClient }, { token: 'env' }], target: i0.ɵɵFactoryTarget.Injectable });
467
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiExternalPickupsService, providedIn: 'root' });
468
+ }
469
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiExternalPickupsService, decorators: [{
470
+ type: Injectable,
471
+ args: [{
472
+ providedIn: 'root'
473
+ }]
474
+ }], ctorParameters: () => [{ type: i1.HttpClient }, { type: undefined, decorators: [{
475
+ type: Inject,
476
+ args: ['env']
477
+ }] }] });
478
+
378
479
  class ApiInvoicesService {
379
480
  environments;
380
481
  http;
@@ -390,13 +491,23 @@ class ApiInvoicesService {
390
491
  get url() {
391
492
  return this.environments.apiInvoicesUrl ?? '';
392
493
  }
494
+ /**
495
+ * Sends an operation document to the server and processes the response.
496
+ *
497
+ * @param {OperationDocumentIn} body - The input data for the operation document.
498
+ * @return {Observable<OperationDocumentOut>} An observable containing the processed operation document output.
499
+ */
500
+ postOperationDocument(body) {
501
+ return this.http.post(`${this.url}/operation/document`, body)
502
+ .pipe(map(({ data }) => data));
503
+ }
393
504
  /**
394
505
  * Fetches and returns the collection receipt data for a given collection ID.
395
506
  *
396
507
  * @param {number} id - The unique identifier of the collection for which the receipt needs to be retrieved.
397
- * @return {Observable<CollectionReceiptOut>} An observable containing the collection receipt data.
508
+ * @return {Observable<PrintCollectionReceiptOut>} An observable containing the collection receipt data.
398
509
  */
399
- printCollectionReceipt(id) {
510
+ getPrintCollectionReceipt(id) {
400
511
  return this.http.get(`${this.url}/operation/print/collection-receipt/${id}`)
401
512
  .pipe(map(({ data }) => data));
402
513
  }
@@ -404,10 +515,10 @@ class ApiInvoicesService {
404
515
  * Handles the account payment operation by sending a POST request to the specified endpoint.
405
516
  * Processes the response and returns the operation data.
406
517
  *
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.
518
+ * @param {OperationAccountPaymentIn} body The payload containing information for the account payment operation.
519
+ * @return {Observable<OperationAccountPaymentOut>} An observable emitting the processed account payment operation data.
409
520
  */
410
- accountPaymentOperation(body) {
521
+ postOperationAccountPayment(body) {
411
522
  return this.http.post(`${this.url}/operation/account-payment`, body)
412
523
  .pipe(map(({ data }) => data));
413
524
  }
@@ -418,7 +529,7 @@ class ApiInvoicesService {
418
529
  * @param body The data required to cancel the payment receipt, encapsulated in a CancelPaymentReceiptIn object.
419
530
  * @return An Observable representing the result of the cancellation. Emits an empty object on success.
420
531
  */
421
- cancelPaymentReceipt(body) {
532
+ postOperationCancelDocument(body) {
422
533
  return this.http.post(`${this.url}/operation/cancel-document`, body)
423
534
  .pipe(map(({ data }) => data));
424
535
  }
@@ -428,10 +539,70 @@ class ApiInvoicesService {
428
539
  * @param {Object} parameters - The parameters required to cancel the invoice, encapsulated in a CancelBillingIn object.
429
540
  * @return {Observable<Object>} An observable that emits the response of the cancellation operation.
430
541
  */
431
- cancelInvoice({ invoiceId, ...body }) {
542
+ postOperationCancelBilling({ invoiceId, ...body }) {
432
543
  return this.http.post(`${this.url}/operation/cancel-billing/${invoiceId}`, body)
433
544
  .pipe(map(({ data }) => data));
434
545
  }
546
+ /**
547
+ * Fetches a list of customer types from the server.
548
+ *
549
+ * @param {QueryParams} params - Query parameters to filter or customize the request.
550
+ * @return {Observable<CustomerTypesOut>} An observable emitting the customer types fetched from the server.
551
+ */
552
+ getCustomerTypes(params) {
553
+ return this.http.get(`${this.url}/customer-types`, { params })
554
+ .pipe(map(({ data }) => data));
555
+ }
556
+ /**
557
+ * Retrieves document types specific to a given country.
558
+ *
559
+ * @param {QueryParams} params - The query parameters containing country-specific information.
560
+ * @return {Observable<CustomerDocumentTypesOut>} An observable emitting the document types available for the specified country.
561
+ */
562
+ getCustomerDocumentTypes(params) {
563
+ return this.http.get(`${this.url}/customer-country-document-types`, { params })
564
+ .pipe(map(({ data }) => data));
565
+ }
566
+ /**
567
+ * Fetches customer invoice details filtered by a custom invoice type.
568
+ *
569
+ * @param {InvoiceTypeCustomParamsIn} params - An object containing the filter parameters for the custom invoice type.
570
+ * @return {Observable<CustomersOut>} An observable containing customer invoice details of the specified type.
571
+ */
572
+ getCustomers(params) {
573
+ return this.http.get(`${this.url}/customers`, { params })
574
+ .pipe(map(({ data }) => data));
575
+ }
576
+ /**
577
+ * Sends a POST request to create or update an external shipment operation.
578
+ *
579
+ * @param {OperationShipmentExternalIn} params - The input parameters for the external shipment operation.
580
+ * @return {Observable<OperationShipmentExternalOut>} An observable that emits the result of the external shipment operation.
581
+ */
582
+ postOperationShipmentExternal(params) {
583
+ return this.http.post(`${this.url}/operation/shipment/external`, params)
584
+ .pipe(map(({ data }) => data));
585
+ }
586
+ /**
587
+ * Processes an external payment operation for a shipment.
588
+ *
589
+ * @param {OperationShipmentExternalIn} params - The input parameters required for the external payment operation.
590
+ * @return {Observable<OperationShipmentExternalOut>} An observable that emits the result of the external payment operation for a shipment.
591
+ */
592
+ postOperationShipmentExternalPayment(params) {
593
+ return this.http.post(`${this.url}/operation/shipment/external/payment`, params)
594
+ .pipe(map(({ data }) => data));
595
+ }
596
+ /**
597
+ * Retrieves and returns billing operation print details for a given document ID.
598
+ *
599
+ * @param {number} documentId - The ID of the document for which to fetch the print billing operation details.
600
+ * @return {Observable<OperationPrintDocumentOut>} An observable emitting the print billing operation details for the specified document.
601
+ */
602
+ getOperationPrintDocument(documentId) {
603
+ return this.http.get(`${this.url}/operation/print/document/${documentId}`)
604
+ .pipe(map(({ data }) => data));
605
+ }
435
606
  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
607
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiInvoicesService, providedIn: 'root' });
437
608
  }
@@ -445,6 +616,64 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
445
616
  args: ['env']
446
617
  }] }, { type: i1.HttpClient }] });
447
618
 
619
+ class ApiOpenItemsService {
620
+ environments;
621
+ http;
622
+ constructor(environments, http) {
623
+ this.environments = environments;
624
+ this.http = http;
625
+ }
626
+ /**
627
+ * Retrieves the API URL for open-items from the environments' configuration.
628
+ *
629
+ * @return {string} The API URL for open-items.
630
+ */
631
+ get url() {
632
+ return this.environments.apiOpenItemsUrl ?? '';
633
+ }
634
+ /**
635
+ * Retrieves a list of open-items based on the provided query parameters.
636
+ *
637
+ * @param {QueryParams} params - The parameters to use for querying open-items.
638
+ * @return {Observable<OpenItemsOut>} An observable that emits the open-item's data.
639
+ */
640
+ getOpenItems(params) {
641
+ return this.http.get(`${this.url}/open-items`, { params })
642
+ .pipe(map(({ data }) => data));
643
+ }
644
+ /**
645
+ * Processes a payment for an open item.
646
+ *
647
+ * @param {PaymentOpenItemIn} body - The payment details for the open item.
648
+ * @return {Observable<PaymentOut>} An observable that emits the result of the payment processing.
649
+ */
650
+ postPayment(body) {
651
+ return this.http.post(`${this.url}/payment`, body)
652
+ .pipe(map(({ data }) => data));
653
+ }
654
+ /**
655
+ * Processes a payment for other invoice.
656
+ *
657
+ * @param {OtherInvoiceIn} body - The payment details for the other invoice.
658
+ * @return {Observable<OtherInvoiceOut>} An observable that emits the result of the payment processing.
659
+ */
660
+ postOtherInvoice(body) {
661
+ return this.http.post(`${this.url}/other-invoices`, body)
662
+ .pipe(map(({ data }) => data));
663
+ }
664
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiOpenItemsService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
665
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiOpenItemsService, providedIn: 'root' });
666
+ }
667
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiOpenItemsService, decorators: [{
668
+ type: Injectable,
669
+ args: [{
670
+ providedIn: 'root'
671
+ }]
672
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
673
+ type: Inject,
674
+ args: ['env']
675
+ }] }, { type: i1.HttpClient }] });
676
+
448
677
  class ApiReportsService {
449
678
  environments;
450
679
  http;
@@ -471,6 +700,52 @@ class ApiReportsService {
471
700
  params
472
701
  }).pipe(map(({ data }) => data));
473
702
  }
703
+ /**
704
+ * Fetches the list of shipments with pending payments.
705
+ *
706
+ * @param {ExistPendingPaymentsIn} params - The parameters to filter pending payment shipments.
707
+ * @return {Observable<ShipmentsReportOut>} An observable emitting the shipments report data.
708
+ */
709
+ shipmentsPendingPayments(params) {
710
+ return this.http.get(`${this.url}/shipments-report`, {
711
+ params: {
712
+ ...params,
713
+ limit: 1,
714
+ offset: 0,
715
+ to_landing: true,
716
+ shipment_status_code: 'PMPEN',
717
+ },
718
+ }).pipe(map(({ data }) => data));
719
+ }
720
+ /**
721
+ * Fetches shipment reports that are pending invoices based on the specified parameters.
722
+ * This method retrieves a filtered list of shipments with pending invoice statuses.
723
+ *
724
+ * @param {ExistPendingInvoicesIn} params - The parameters to filter the pending invoices, including
725
+ * shipment status codes, and pagination options.
726
+ * @return {Observable<ShipmentsReportOut>} An observable that emits the shipment report data based on the filter criteria.
727
+ */
728
+ shipmentsPendingInvoices(params) {
729
+ return this.http.get(`${this.url}/shipments-report`, {
730
+ params: {
731
+ ...params,
732
+ limit: 1,
733
+ offset: 0,
734
+ to_landing: true,
735
+ 'shipment_status_code[in]': 'IPMPE,IMPEN,IPPEN',
736
+ },
737
+ }).pipe(map(({ data }) => data));
738
+ }
739
+ /**
740
+ * Fetches shipment reports based on the provided query parameters.
741
+ *
742
+ * @param {QueryParams} params - The query parameters used to filter or define the shipment reports.
743
+ * @return {Observable<ShipmentsReportOut>} An observable emitting the shipment report data.
744
+ */
745
+ getShipmentsReport(params) {
746
+ return this.http.get(`${this.url}/shipments-report`, { params })
747
+ .pipe(map(({ data }) => data));
748
+ }
474
749
  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
750
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiReportsService, providedIn: 'root' });
476
751
  }
@@ -502,21 +777,24 @@ class ApiSecurityService {
502
777
  return this.environments.apiSecurityUrl ?? '';
503
778
  }
504
779
  /**
505
- * Authenticates a user with the provided credentials and role.
780
+ * Handles the login authentication request by sending the login data to the authentication endpoint.
781
+ *
782
+ * @param {AuthLoginIn} body The payload containing login credentials.
783
+ * @return {Observable<AuthLoginOut>} An observable emitting the authentication response data.
784
+ */
785
+ postAuthLogin(body) {
786
+ return this.http.post(`${this.url}/auth/login`, body)
787
+ .pipe(map(({ data }) => data), tap(({ access_token }) => this.cookie.set(this.environments.authCookie, access_token, { path: '/' })));
788
+ }
789
+ /**
790
+ * Handles the user login process by sending user credentials to the authentication endpoint.
506
791
  *
507
- * @param {Object} param0 - The login input object.
508
- * @param {string} param0.username - The username of the user.
509
- * @param {string} param0.password - The password of the user.
510
- * @param {string} param0.role - The role of the user.
511
- * @return {Observable<LoginOut>} An observable emitting the login output object.
792
+ * @param {AuthUserLoginIn} body - The request payload containing user login details such as username and password.
793
+ * @return {Observable<AuthLoginOut>} An observable that emits the authenticated user's login data upon successful login.
512
794
  */
513
- login({ username, password, role, }) {
514
- return this.http.post(`${this.url}/auth/login`, {
515
- system_name: 'CRA',
516
- username,
517
- password,
518
- role,
519
- }).pipe(map(({ data }) => data), tap(({ access_token }) => this.cookie.set(this.environments.authCookie, access_token, { path: '/' })));
795
+ postAuthUserLogin(body) {
796
+ return this.http.post(`${this.url}/auth/user-login`, body)
797
+ .pipe(map(({ data }) => data));
520
798
  }
521
799
  /**
522
800
  * Logs out the current user by making a POST request to the logout endpoint.
@@ -525,7 +803,7 @@ class ApiSecurityService {
525
803
  *
526
804
  * @return {Observable<{}>} An observable that emits the server's response to the logout request.
527
805
  */
528
- logout() {
806
+ postAuthLogout() {
529
807
  return this.http.post(`${this.url}/auth/logout`, null)
530
808
  .pipe(map(({ data }) => data), tap(() => this.cookie.delete(this.environments.authCookie, '/')));
531
809
  }
@@ -537,9 +815,9 @@ class ApiSecurityService {
537
815
  * @param {string} params.modelId - The ID of the model.
538
816
  * @param {string} [params.token] - Optional authorization token.
539
817
  *
540
- * @return {Observable<CreateSessionOut>} An observable containing the created session details.
818
+ * @return {Observable<SessionOut>} An observable containing the created session details.
541
819
  */
542
- createSession({ modelType, modelId, token, }) {
820
+ postSession({ modelType, modelId, token, }) {
543
821
  let headers = new HttpHeaders({});
544
822
  if (token) {
545
823
  headers = headers.set('Authorization', `Bearer ${token}`);
@@ -556,9 +834,9 @@ class ApiSecurityService {
556
834
  * Sends a GET request to the endpoint '/auth/me' to retrieve information
557
835
  * about the currently authenticated user.
558
836
  *
559
- * @return {Observable<MeOut>} An observable that emits the authenticated user's data.
837
+ * @return {Observable<AuthMeOut>} An observable that emits the authenticated user's data.
560
838
  */
561
- me() {
839
+ getAuthMe() {
562
840
  return this.http.get(`${this.url}/auth/me`)
563
841
  .pipe(map(({ data }) => data));
564
842
  }
@@ -568,7 +846,7 @@ class ApiSecurityService {
568
846
  * @param token The JWT token used for authorization.
569
847
  * @return An Observable that emits the user's details encapsulated in a MeOut object.
570
848
  */
571
- otherMe(token) {
849
+ getOtherMe(token) {
572
850
  return this.http.get(`${this.url}/auth/me`, {
573
851
  headers: {
574
852
  Authorization: `Bearer ${token}`
@@ -581,18 +859,41 @@ class ApiSecurityService {
581
859
  * @param {number} id - The unique identifier of the user to be fetched.
582
860
  * @return {Observable<GetUserOut>} An observable containing the user information.
583
861
  */
584
- user(id) {
862
+ getUser(id) {
585
863
  return this.http.get(`${this.url}/users/${id}`)
586
864
  .pipe(map(({ data }) => data));
587
865
  }
866
+ /**
867
+ * Fetches a list of users from the server based on the specified query parameters.
868
+ *
869
+ * @param {QueryParams} params - The query parameters to filter the list of users.
870
+ * @return {Observable<GetUsersOut>} An observable that emits the list of users retrieved from the server.
871
+ */
872
+ getUsers(params) {
873
+ return this.http.get(`${this.url}/users`, { params })
874
+ .pipe(map(({ data }) => data));
875
+ }
876
+ /**
877
+ * Updates the information of a specified user on the server.
878
+ *
879
+ * @param {Object} params - The parameter object.
880
+ * @param {Object} params.user - The user object containing updated data.
881
+ * @param {string} params.user.id - The unique identifier of the user to be updated.
882
+ *
883
+ * @return {void} This method does not return a value.
884
+ */
885
+ putUsers({ user }) {
886
+ return this.http.put(`${this.url}/users/${user.id}`, user)
887
+ .pipe(map(({ data }) => data));
888
+ }
588
889
  /**
589
890
  * Changes the language for the authenticated user.
590
891
  *
591
892
  * @param {Object} params - The input parameters for changing the language.
592
893
  * @param {string} params.languageId - The ID of the new language to be set.
593
- * @return {Observable<ApiSuccess<MeOut>>} An observable that emits the result of the language change request.
894
+ * @return {Observable<ApiSuccess<AuthMeOut>>} An observable that emits the result of the language change request.
594
895
  */
595
- changeLanguage({ languageId }) {
896
+ putChangeLanguage({ languageId }) {
596
897
  return this.http.put(`${this.url}/auth/me`, {
597
898
  language_id: languageId
598
899
  }).pipe(map(({ data }) => data));
@@ -601,12 +902,11 @@ class ApiSecurityService {
601
902
  * Retrieves a list of roles with their permissions.
602
903
  *
603
904
  * @param {QueryParams} params - The query parameters to filter the roles.
604
- * @returns {Observable<RolePermissionsIn[]>} An observable that emits an array of role permissions.
905
+ * @returns {Observable<RoleIn[]>} An observable that emits an array of role permissions.
605
906
  */
606
907
  getRoles(params) {
607
- return this.http.get(`${this.url}/roles`, {
608
- params
609
- }).pipe(map(({ data }) => data));
908
+ return this.http.get(`${this.url}/roles`, { params })
909
+ .pipe(map(({ data }) => data));
610
910
  }
611
911
  /**
612
912
  * Retrieves the role types from the API.
@@ -615,38 +915,26 @@ class ApiSecurityService {
615
915
  * @returns {Observable<RoleTypesOut>} An observable containing the role types output.
616
916
  */
617
917
  getRoleTypes(params) {
618
- return this.http.get(`${this.url}/role-types`, {
619
- params
620
- }).pipe(map(({ data }) => data));
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));
918
+ return this.http.get(`${this.url}/role-types`, { params })
919
+ .pipe(map(({ data }) => data));
632
920
  }
633
921
  /**
634
922
  * Retrieves roles by the specified ID.
635
923
  *
636
- * @param params - The ID of the role to retrieve.
924
+ * @param id - The ID of the role to retrieve.
637
925
  * @returns An Observable that emits the role data.
638
926
  */
639
- getRolesById(params) {
640
- return this.http.get(`${this.url}/roles/${params}`)
927
+ getRole(id) {
928
+ return this.http.get(`${this.url}/roles/${id}`)
641
929
  .pipe(map(({ data }) => data));
642
930
  }
643
931
  /**
644
932
  * Creates a new role with the specified permissions.
645
933
  *
646
- * @param {RolePermissionsIn} body - The permissions and details for the new role.
647
- * @returns {Observable<ModulePermissionsOut>} An observable containing the created role's permissions.
934
+ * @param {RoleIn} body - The permissions and details for the new role.
935
+ * @returns {Observable<RoleOut>} An observable containing the created role's permissions.
648
936
  */
649
- createRole(body) {
937
+ postRole(body) {
650
938
  return this.http.post(`${this.url}/roles`, body)
651
939
  .pipe(map(({ data }) => data));
652
940
  }
@@ -657,7 +945,7 @@ class ApiSecurityService {
657
945
  * @param body - The new permissions to assign to the role.
658
946
  * @returns An Observable that emits the updated module permissions.
659
947
  */
660
- updateRolePermissions(id, body) {
948
+ putRole(id, body) {
661
949
  return this.http.put(`${this.url}/roles/${id}`, body)
662
950
  .pipe(map(({ data }) => data));
663
951
  }
@@ -667,10 +955,36 @@ class ApiSecurityService {
667
955
  * @param {number} id - The unique identifier of the role whose permissions are to be deleted.
668
956
  * @returns {Observable<{}>} An observable that emits the result of the delete operation.
669
957
  */
670
- deleteRolePermissions(id) {
958
+ deleteRole(id) {
671
959
  return this.http.delete(`${this.url}/roles/${id}`)
672
960
  .pipe(map(({ data }) => data));
673
961
  }
962
+ /**
963
+ * Retrieves a list of modules and permissions
964
+ *
965
+ * @param queryParams - The query parameters to filter the modules.
966
+ * @returns Observable<ModulesOut[]> - An observable that emits an array of modules and permissions.
967
+ */
968
+ getModules(queryParams) {
969
+ return this.http.get(`${this.url}/modules`, {
970
+ params: queryParams
971
+ }).pipe(map(({ data }) => data));
972
+ }
973
+ /**
974
+ * Retrieves a list of modules and permissions
975
+ *
976
+ * @param params.token - Custom token for authorization.
977
+ * @param params.queryParams - The query parameters to filter the modules.
978
+ * @returns Observable<ModulesOut[]> - An observable that emits an array of modules and permissions.
979
+ */
980
+ getModulesByToken(params) {
981
+ return this.http.get(`${this.url}/modules`, {
982
+ params: params.queryParams,
983
+ headers: {
984
+ Authorization: `Bearer ${params.token}`
985
+ }
986
+ }).pipe(map(({ data }) => data));
987
+ }
674
988
  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
989
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiSecurityService, providedIn: 'root' });
676
990
  }
@@ -706,10 +1020,20 @@ class ApiShipmentsService {
706
1020
  * @return {Observable<ValidateAccountIn>} An observable that emits the fetched parameter values
707
1021
  * @param body
708
1022
  */
709
- validateAccount(body) {
1023
+ postValidateAccount(body) {
710
1024
  return this.http.post(`${this.url}/accounts`, body)
711
1025
  .pipe(map(({ data }) => data));
712
1026
  }
1027
+ /**
1028
+ * Sends a POST request to the shipments manifest endpoint with the provided body.
1029
+ *
1030
+ * @param body - The request payload of type `ManifestMultipleIn`.
1031
+ * @returns An observable that emits the response data of type `ManifestMultipleOut`.
1032
+ */
1033
+ postManifestMultiple(body) {
1034
+ return this.http.post(`${this.url}/shipments/manifest`, body)
1035
+ .pipe(map(({ data }) => data));
1036
+ }
713
1037
  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
1038
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiShipmentsService, providedIn: 'root' });
715
1039
  }
@@ -723,6 +1047,117 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
723
1047
  args: ['env']
724
1048
  }] }, { type: i1.HttpClient }] });
725
1049
 
1050
+ class WebSocketsService {
1051
+ environments;
1052
+ pusher;
1053
+ constructor(environments) {
1054
+ this.environments = environments;
1055
+ this.pusher = null;
1056
+ this.connect()
1057
+ .then((pusher) => {
1058
+ if (!pusher)
1059
+ return;
1060
+ this.pusher = pusher;
1061
+ });
1062
+ }
1063
+ /**
1064
+ * Publishes an event to the specified channel with the given data.
1065
+ *
1066
+ * @param {Channel} channel - The channel instance where the event will be published.
1067
+ * @param {string} eventName - The name of the event to be published.
1068
+ * @param {T} data - The payload data to be sent with the event.
1069
+ * @return {Promise<boolean>} A promise that resolves to a boolean indicating
1070
+ * whether the event was successfully triggered on the channel.
1071
+ */
1072
+ async pub(channel, eventName, data) {
1073
+ return channel.trigger(`client-${eventName}`, data);
1074
+ }
1075
+ /**
1076
+ * Subscribes to a specified channel, retrying multiple times upon failure.
1077
+ *
1078
+ * @param {string} channelName - The name of the channel to be subscribed to.
1079
+ * @return {Promise<Channel>} A promise that resolves to the subscribed channel object if successful.
1080
+ * @throws {Error} If the subscription fails after the maximum number of retry attempts.
1081
+ */
1082
+ async channelSub(channelName) {
1083
+ const attempts = 3;
1084
+ for (let attempt = 0; attempt <= attempts; attempt++) {
1085
+ const channel = this.pusher?.channel(channelName);
1086
+ if (channel?.subscribed) {
1087
+ return channel;
1088
+ }
1089
+ this.pusher?.subscribe(channelName);
1090
+ if (attempt < attempts) {
1091
+ await this.wait();
1092
+ }
1093
+ }
1094
+ throw new Error(`Failed to subscribe to channel "${channelName}" after ${attempts} attempts.`);
1095
+ }
1096
+ /**
1097
+ * Binds an event listener to a specified event on a given channel using Pusher or a Channel object,
1098
+ * and returns an Observable that emits event data of type T.
1099
+ *
1100
+ * @param {Channel|string} channel - The channel to bind the event to. It can be a Channel object or a string representing the channel name.
1101
+ * @param {string} event - The name of the event to bind to the channel.
1102
+ * @return {Observable<T>} An Observable that emits data of type T when the specified event is triggered.
1103
+ */
1104
+ eventBind(channel, event) {
1105
+ return new Observable((subscriber) => {
1106
+ if (channel?.name) {
1107
+ channel.bind(event, (data) => subscriber.next(data));
1108
+ }
1109
+ else {
1110
+ this.pusher?.subscribe(channel)
1111
+ .bind(event, (data) => subscriber.next(data));
1112
+ }
1113
+ });
1114
+ }
1115
+ /**
1116
+ * Unbinds an event from the specified channel and returns an observable
1117
+ * that emits data when the event callback is triggered.
1118
+ *
1119
+ * @param {Channel} channel - The channel object from which the event should be unbound.
1120
+ * @param {string} event - The name of the event to unbind.
1121
+ * @return {Observable<T>} An observable that emits data from the unbound event callback.
1122
+ */
1123
+ eventUnbind(channel, event) {
1124
+ return new Observable((subscriber) => channel.unbind(event, (data) => subscriber.next(data)));
1125
+ }
1126
+ connect() {
1127
+ return new Promise((resolve) => {
1128
+ const { sockets } = this.environments;
1129
+ if (!sockets)
1130
+ return resolve(false);
1131
+ const pusher = new Pusher(sockets.app_key, {
1132
+ wsHost: sockets.url,
1133
+ wsPort: sockets.port,
1134
+ enabledTransports: ['wss', 'ws'],
1135
+ forceTLS: false,
1136
+ enableStats: false,
1137
+ });
1138
+ if (sockets.debug) {
1139
+ Pusher.logToConsole = true;
1140
+ }
1141
+ return resolve(pusher);
1142
+ });
1143
+ }
1144
+ async wait() {
1145
+ const waitTime = 3 * 1000;
1146
+ return new Promise((resolve) => setTimeout(resolve, waitTime));
1147
+ }
1148
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: WebSocketsService, deps: [{ token: 'env' }], target: i0.ɵɵFactoryTarget.Injectable });
1149
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: WebSocketsService, providedIn: 'root' });
1150
+ }
1151
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: WebSocketsService, decorators: [{
1152
+ type: Injectable,
1153
+ args: [{
1154
+ providedIn: 'root',
1155
+ }]
1156
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1157
+ type: Inject,
1158
+ args: ['env']
1159
+ }] }] });
1160
+
726
1161
  class CryptoService {
727
1162
  environments;
728
1163
  constructor(environments) {
@@ -895,6 +1330,71 @@ function httpCachingInterceptor(req, next) {
895
1330
  }));
896
1331
  }
897
1332
 
1333
+ /**
1334
+ * Convert an object of key-value pairs into a URL query string.
1335
+ *
1336
+ * @param {Object} params - The key-value pairs to converted into a query string.
1337
+ *
1338
+ * @return {string} - The generated query string.
1339
+ */
1340
+ const queryString = (params) => {
1341
+ const queryElements = [];
1342
+ Object.entries(params).forEach(([key, value]) => {
1343
+ if (Array.isArray(value)) {
1344
+ const arrayQuery = value
1345
+ .map((item) => `${encodeURIComponent(key)}=${encodeURIComponent(item)}`)
1346
+ .join('&');
1347
+ queryElements.push(arrayQuery);
1348
+ }
1349
+ else {
1350
+ const encodedQuery = `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
1351
+ queryElements.push(encodedQuery);
1352
+ }
1353
+ });
1354
+ const queryString = queryElements.join('&');
1355
+ return queryString.length ? `?${queryString}` : '';
1356
+ };
1357
+ /**
1358
+ * Creates an instance of HttpParams using the provided params object.
1359
+ *
1360
+ * @param {Object} params - The object containing the params to the HttpParams constructor.
1361
+ *
1362
+ * @returns {HttpParams} - An instance of HttpParams created from the params object.
1363
+ */
1364
+ const httpParams = (params) => new HttpParams({
1365
+ fromObject: params
1366
+ });
1367
+ /**
1368
+ * Returns the headers for generating PDF files.
1369
+ *
1370
+ * @param {string} format - The format of the headers, 'object' or 'http_header'.
1371
+ *
1372
+ * @returns {HttpHeaders | { [header: string]: string | string[] }} - The headers for generating PDF files.
1373
+ */
1374
+ const pdfHeaders = (format = 'object') => {
1375
+ const headers = {
1376
+ Accept: 'application/pdf'
1377
+ };
1378
+ return format === 'object'
1379
+ ? headers
1380
+ : new HttpHeaders(headers);
1381
+ };
1382
+ /**
1383
+ * Returns the headers for generating XML files.
1384
+ *
1385
+ * @param {string} format - The format of the headers, 'object' or 'http_header'.
1386
+ *
1387
+ * @returns {HttpHeaders | { [header: string]: string | string[] }} - The headers for generating XML files.
1388
+ */
1389
+ const xmlHeaders = (format = 'object') => {
1390
+ const headers = {
1391
+ Accept: 'application/xml',
1392
+ };
1393
+ return format === 'object'
1394
+ ? headers
1395
+ : new HttpHeaders(headers);
1396
+ };
1397
+
898
1398
  /*
899
1399
  * Public API Surface of ngx-services
900
1400
  */
@@ -903,5 +1403,5 @@ function httpCachingInterceptor(req, next) {
903
1403
  * Generated bundle index. Do not edit.
904
1404
  */
905
1405
 
906
- export { ApiCompaniesService, ApiInvoicesService, ApiReportsService, ApiSecurityService, ApiShipmentsService, CryptoService, ENVIRONMENT_TOKEN, NgxServicesModule, apiHeadersInterceptor, apiTokenInterceptor, httpCachingInterceptor, httpParams, pdfHeaders, queryString, xmlHeaders };
1406
+ export { ApiBillingDOService, ApiBillingMxService, ApiCompaniesService, ApiExternalPickupsService, ApiInvoicesService, ApiOpenItemsService, ApiReportsService, ApiSecurityService, ApiShipmentsService, CryptoService, ENVIRONMENT_TOKEN, NgxServicesModule, WebSocketsService, apiHeadersInterceptor, apiTokenInterceptor, httpCachingInterceptor, httpParams, pdfHeaders, queryString, xmlHeaders };
907
1407
  //# sourceMappingURL=experteam-mx-ngx-services.mjs.map